big commit

This commit is contained in:
omair saleh
2021-03-22 08:46:33 +08:00
parent 307aff1c3f
commit 9fe0757baf
75 changed files with 2587 additions and 425 deletions
@@ -0,0 +1,21 @@
<?php
namespace App\Http\Controllers\Addresses;
use App\Classes\Modules\Addresses\ControllersLogic\CreateAddressLogic;
use App\Classes\Modules\Addresses\ControllersLogic\SetAddressDefaultLogic;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class SetAddressDefaultController
{
/**
* @param Request $request
* @param SetAddressDefaultLogic $logic
* @return JsonResponse
*/
public function set(Request $request, SetAddressDefaultLogic $logic): JsonResponse {
return $logic->execute($request);
}
}
@@ -0,0 +1,20 @@
<?php
namespace App\Http\Controllers\Companies;
use App\Classes\Modules\Companies\ControllersLogic\UpdateCompanyIdentificationDocumentLogic;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class UpdateCompanyIdentificationDocumentController
{
/**
* @param Request $request
* @param UpdateCompanyIdentificationDocumentLogic $logic
* @return JsonResponse
*/
public function update(Request $request, UpdateCompanyIdentificationDocumentLogic $logic): JsonResponse {
return $logic->execute($request);
}
}
@@ -11,6 +11,7 @@ use App\Models\Company;
use App\Models\CompanyConnections;
use App\Models\Order;
use Illuminate\Http\Request;
use Barryvdh\DomPDF\PDF;
class OrderController
{
@@ -26,8 +27,8 @@ class OrderController
$order->company_id = $company->id;
$order->order_number = $generatesUniqueOrderNumber->execute();
$order->forwarder_id = 1;
$order->address_id = $company->addresses()->first()->id;
$order->contact_id = $company->contacts()->first()->id;
$order->address_id = $company->addresses->first()->id;
$order->contact_id = $company->contacts->first()->id;
$order->current_step = 'MS_WAREHOUSE_RECEIVING';
$order->multiple_batch = false;
$order->complete = false;
@@ -59,7 +60,7 @@ class OrderController
HttpStatus::OK_WITH_MESSAGE, json_decode(OrderResource::collection($orders)->response()->getContent(), true)))->handler();
}
public function download(String $orderId){
public function download(String $orderId, PDF $pdf){
/** @var Order $order */
$order = order::findOrFail($orderId);
/** @var Company $warehouse */
@@ -78,7 +79,7 @@ class OrderController
return view('pages.pdf.qr', $data);
return $this->pdf->loadView('pages.pdf.qr', $data)->stream();
return $pdf->loadView('pages.pdf.qr', $data)->download();
}
}
-271
View File
@@ -1,271 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Classes\Modules\Accounts\ControllersLogic\CheckEmailLogic;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class TestController
{
public function index(){
$cookies = $this->getToken();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://portalvt.azurewebsites.net/Services/DataControllerService.asmx/GetPage');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"controller":"WarehouseList","view":"grid1","request":{"PageSize":10000000, "Filter":["ParcelDate:>%js%\"2020-01-10T00:00:00.000\"\u0000"]}}');
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
$headers = array();
$headers[] = 'Connection: keep-alive';
$headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36';
$headers[] = 'X-Requested-With: XMLHttpRequest';
$headers[] = 'Content-Type: application/json; charset=UTF-8';
$headers[] = 'Accept: */*';
$headers[] = 'Origin: http://portalvt.azurewebsites.net';
$headers[] = 'Referer: http://portalvt.azurewebsites.net/Pages/WarehouseList.aspx';
$headers[] = 'Accept-Language: en-US,en;q=0.9';
$headers[] = 'Cookie: '.implode('; ', $cookies);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
dd(json_decode($result));
}
private function getToken(){
$cookies = $this->getCookies();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://portalvt.azurewebsites.net/Services/DataControllerService.asmx/Login');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"username":"CIEF","password":"0122120880","createPersistentCookie":true}');
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
$headers = array();
$headers[] = 'Connection: keep-alive';
$headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36';
$headers[] = 'X-Requested-With: XMLHttpRequest';
$headers[] = 'Content-Type: application/json; charset=UTF-8';
$headers[] = 'Accept: */*';
$headers[] = 'Origin: http://portalvt.azurewebsites.net';
$headers[] = 'Referer: http://portalvt.azurewebsites.net/Login.aspx?ReturnUrl=%2fPages%2fHome.aspx';
$headers[] = 'Accept-Language: en-US,en;q=0.9';
$headers[] = 'Cookie: '.implode('; ', $cookies);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
$cookies[] = 'AppVTCC='.json_decode($result)->d->Token;
return $cookies;
}
private function getCookies(){
$cookies = [];
$curl_handle = curl_init('http://portalvt.azurewebsites.net/Login.aspx');
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($curl_handle, CURLOPT_HEADER, true);
$data = curl_exec($curl_handle);
$responseHeader= substr($data,0, intval(curl_getinfo($curl_handle, CURLINFO_HEADER_SIZE)));
$endPosition = 0;
while(true) {
$startPosition = strpos($responseHeader, 'Set-Cookie: ', $endPosition);
if (!$startPosition){break;}
$startPosition += 12;
$endPosition = strpos($responseHeader, ';', $startPosition);
$cookies[] = substr($responseHeader,$startPosition,$endPosition-$startPosition);
}
return $cookies;
}
public function index2() {
// curl 'http://portalvt.azurewebsites.net/Services/DataControllerService.asmx/Login' \
// -H 'Connection: keep-alive' \
// -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36' \
// -H 'X-Requested-With: XMLHttpRequest' \
// -H 'Content-Type: application/json; charset=UTF-8' \
// -H 'Accept: */*' \
// -H 'Origin: http://portalvt.azurewebsites.net' \
// -H 'Referer: http://portalvt.azurewebsites.net/Login.aspx?ReturnUrl=%2fPages%2fHome.aspx' \
// -H 'Accept-Language: en-US,en;q=0.9' \
// -H 'Cookie: ASP.NET_SessionId=cxe2tgbsi03jtg2p0nlfdcrl; ARRAffinity=2950dd3bc3c86410bd48fe08ed3595e06670f25d93c162510d25040b02f01a67' \
// --data-binary '{"username":"CIEF","password":"0122120880","createPersistentCookie":true}' \
// --compressed \
// --insecure
header('Content-Type: text/plain; charset=utf-8');
$post = array('createPersistentCookie'=>true,
'username'=>'CIEF',
'password'=>'0122120880');
$request = array();
$request[] = 'Connection: keep-alive';
$request[] = 'Pragma: no-cache';
$request[] = 'Cache-Control: no-cache';
$request[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8';
$request[] = 'User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36';
$request[] = 'DNT: 1';
$request[] = 'http://portalvt.azurewebsites.net/Login.aspx?ReturnUrl=%2fPages%2fHome.aspx';
$request[] = 'Accept-Encoding: gzip, deflate';
$request[] = 'Accept-Language: en-US,en;q=0.8';
$request[] = 'Content-Type:multipart/form-data';
$url = 'http://portalvt.azurewebsites.net/Login.aspx';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_HTTPHEADER, $request);
curl_setopt($ch, CURLOPT_ENCODING,"");
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT,10);
curl_setopt($ch, CURLOPT_FAILONERROR,true);
curl_setopt($ch, CURLOPT_ENCODING,"");
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_HEADER, true);
$data = curl_exec($ch);
if (curl_errno($ch)){
$data .= 'Retreive Base Page Error: ' . curl_error($ch);
var_dump($data);
}
else {
$info = rawurldecode(var_export(curl_getinfo($ch),true));
$skip = intval(curl_getinfo($ch, CURLINFO_HEADER_SIZE));
$responseHeader= substr($data,0,$skip);
// The folowing line is for debug
// echo "$info\n$responseHeader\n$data\n\n";
// Get the cookies:
$e = 0;
while(true){
$s = strpos($responseHeader,'Set-Cookie: ',$e);
if (!$s){break;}
$s += 12;
$e = strpos($responseHeader,';',$s);
$cookie = substr($responseHeader,$s,$e-$s) ;
$s = strpos($cookie,'=');
$key = substr($cookie,0,$s);
$value = substr($cookie,$s);
$cookies[$key] = $value;
}
// Create cookie for subsequent Requests:
$cookie = '';
$show = '';
$head = '';
$delim = '';
foreach ($cookies as $k => $v){
$cookie .= "$delim$k$v";
$delim = '; ';
}
}
var_dump($cookies);
$request = array();
$request[] = 'Host: portalvt.azurewebsites.net';
$request[] = 'Connection: keep-alive';
$request[] = 'Pragma: no-cache';
$request[] = 'Cache-Control: no-cache';
$request[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8';
$request[] = 'User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36';
$request[] = 'DNT: 1';
$request[] = 'Referer: http://portalvt.azurewebsites.net/Login.aspx?ReturnUrl=%2fPages%2fHome.aspx';
$request[] = 'Accept-Encoding: gzip, deflate';
$request[] = 'Accept-Language: en-US,en;q=0.8';
$url = 'http://portalvt.azurewebsites.net/Login.aspx';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $request);
curl_setopt($ch, CURLOPT_ENCODING,"");
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT,10);
curl_setopt($ch, CURLOPT_FAILONERROR,true);
curl_setopt($ch, CURLOPT_ENCODING,"");
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, false);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_COOKIESESSION , true );
curl_setopt($ch, CURLOPT_COOKIE, $cookie );
$data = curl_exec($ch);
$skip = intval(curl_getinfo($ch, CURLINFO_HEADER_SIZE));
echo substr($data,$skip); //do not transmit header
// if (curl_errno($ch)){
// $data .= 'Retreive Base Page Error: ' . curl_error($ch);
// var_dump($data);
// }
// else {
// $info = rawurldecode(var_export(curl_getinfo($ch), true));
//
// // Get the cookies:
//
// $skip = intval(curl_getinfo($ch, CURLINFO_HEADER_SIZE));
// $responseHeader = substr($data, 0, $skip);
//
// echo "$info\n$responseHeader\n$data\n\n";
//
// $e = 0;
// while (true) {
// $s = strpos($responseHeader, 'Set-Cookie: ', $e);
// if (!$s) {
// break;
// }
// $s += 12;
// $e = strpos($responseHeader, ';', $s);
// $cookie = substr($responseHeader, $s, $e - $s);
// $s = strpos($cookie, '=');
// $key = substr($cookie, 0, $s);
// $value = substr($cookie, $s);
// $cookies[$key] = $value;
// }
// }
}
}
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace App\Http\Controllers;
class invoiceClass
{
$user = User::fetch();
public function execute(){
$company = $user->company();
$price = $company->price();
$order = Order::fetch();
$items = $order->items();
$deliveryAddress = address();
$invoice = Invoice::create([
$order,
$items
]);
$convertToPdf = $invoice->pdf();
$email = email()->pdf();
solid
}
}
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace App\Http\Controllers;
class preformaClass
{
public function execute(){
$user = User::fetch();
$company = $user->company();
$price = $company->price();
$order = Order::fetch();
$items = $order->items();
$deliveryAddress = address();
$invoice = Performa::create([
$order,
$items
]);
$convertToPdf = $invoice->pdf();
$email = email()->pdf();
}
}
+4 -2
View File
@@ -3,6 +3,7 @@
namespace App\Http\Resources;
use App\Classes\ValueObjects\Constants\AccountStatus;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Models\CompanyConnections;
use Illuminate\Http\Resources\Json\JsonResource;
@@ -22,9 +23,10 @@ class CompanyResource extends JsonResource
'marking' => CompanyConnections::where('module_one', $this->modules->first()->id)->first()->marking,
'name' => $this->name,
'type' => $this->type,
'status' => AccountStatus::STATUS[$this->status],
'status' => $this->status,
'delivery_address' => new AddressResource($this->deliveryAddress),
'contact' => new ContactResource($this->contacts->first())
'contact' => new ContactResource($this->contacts->first()),
'total_orders' => count($this->orders)
];
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class DocumentResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'document_type' => $this->document_type,
'reference' => $this->reference,
'status' => (int) $this->status,
'approved_by' => (int) $this->approved_by,
'files' => $this->files()->get()
];
}
}