Compare commits
2 Commits
185da1edbb
...
0ed98c96ee
| Author | SHA1 | Date | |
|---|---|---|---|
| 0ed98c96ee | |||
| 38da1b56ce |
@@ -33,13 +33,14 @@ class AuthController extends Controller
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'access_token' => $tokenResult->accessToken,
|
||||
'token_type' => 'Bearer',
|
||||
'expires_at' => Carbon::parse($tokenResult->token->expires_at)->toDateTimeString(),
|
||||
'userid' => $user->id,
|
||||
'role' => $user->role_id,
|
||||
'verified' => $user->phone_verified_at,
|
||||
'reported' => $user->reported,
|
||||
'access_token' => $tokenResult->accessToken,
|
||||
'token_type' => 'Bearer',
|
||||
'expires_at' => Carbon::parse($tokenResult->token->expires_at)->toDateTimeString(),
|
||||
'userid' => $user->id,
|
||||
'role' => $user->role_id,
|
||||
'verified' => $user->phone_verified_at,
|
||||
'reported' => $user->reported,
|
||||
'profile_photo' => $user->profile_photo,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -53,9 +54,10 @@ class AuthController extends Controller
|
||||
return response()->json(['message' => 'Token de Firebase inválido'], 401);
|
||||
}
|
||||
|
||||
$uid = $verifiedToken->claims()->get('sub');
|
||||
$email = $verifiedToken->claims()->get('email');
|
||||
$name = $verifiedToken->claims()->get('name') ?? 'Usuario';
|
||||
$uid = $verifiedToken->claims()->get('sub');
|
||||
$email = $verifiedToken->claims()->get('email');
|
||||
$name = $verifiedToken->claims()->get('name') ?? 'Usuario';
|
||||
$picture = $verifiedToken->claims()->get('picture');
|
||||
|
||||
// Buscar por firebase uid primero, luego por email para hacer merge si ya existía cuenta
|
||||
$user = User::where('social_id', 'firebase|' . $uid)->first();
|
||||
@@ -65,31 +67,38 @@ class AuthController extends Controller
|
||||
}
|
||||
|
||||
if ($user) {
|
||||
// Vincular uid de Firebase si aún no lo tiene (merge de cuenta existente)
|
||||
$changed = false;
|
||||
if (!$user->social_id) {
|
||||
$user->social_id = 'firebase|' . $uid;
|
||||
$user->save();
|
||||
$changed = true;
|
||||
}
|
||||
if ($picture && $user->profile_photo !== $picture) {
|
||||
$user->profile_photo = $picture;
|
||||
$changed = true;
|
||||
}
|
||||
if ($changed) $user->save();
|
||||
} else {
|
||||
$user = User::create([
|
||||
'name' => $name,
|
||||
'email' => $email,
|
||||
'social_id'=> 'firebase|' . $uid,
|
||||
'role_id' => 1,
|
||||
'password' => null,
|
||||
'name' => $name,
|
||||
'email' => $email,
|
||||
'social_id' => 'firebase|' . $uid,
|
||||
'role_id' => 1,
|
||||
'password' => null,
|
||||
'profile_photo' => $picture,
|
||||
]);
|
||||
}
|
||||
|
||||
$tokenResult = $user->createToken('Firebase Token');
|
||||
|
||||
return response()->json([
|
||||
'access_token' => $tokenResult->accessToken,
|
||||
'token_type' => 'Bearer',
|
||||
'expires_at' => Carbon::parse($tokenResult->token->expires_at)->toDateTimeString(),
|
||||
'userid' => $user->id,
|
||||
'role' => $user->role_id,
|
||||
'verified' => $user->phone_verified_at,
|
||||
'reported' => $user->reported,
|
||||
'access_token' => $tokenResult->accessToken,
|
||||
'token_type' => 'Bearer',
|
||||
'expires_at' => Carbon::parse($tokenResult->token->expires_at)->toDateTimeString(),
|
||||
'userid' => $user->id,
|
||||
'role' => $user->role_id,
|
||||
'verified' => $user->phone_verified_at,
|
||||
'reported' => $user->reported,
|
||||
'profile_photo' => $user->profile_photo,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ use App\Models\iChambaParameter;
|
||||
use App\Models\Suppliers;
|
||||
use App\Models\Categories;
|
||||
use App\Models\Cards;
|
||||
use App\Models\Technician;
|
||||
use App\Models\Postulations;
|
||||
use App\Models\CurrentContracts;
|
||||
use App\Models\FinishedContracts;
|
||||
@@ -159,28 +160,14 @@ class ContractController extends Controller
|
||||
|
||||
public function create(Request $request) {
|
||||
|
||||
// Si el bypass está activo, usar reglas relajadas
|
||||
$paymentBypass = env('PAYMENT_BYPASS', false);
|
||||
|
||||
if ($paymentBypass) {
|
||||
$rules = [
|
||||
'postulation_id' => 'required|numeric',
|
||||
'supplier_id' => 'required|numeric',
|
||||
'card_id' => 'required|string',
|
||||
'code' => 'required|string',
|
||||
'device_id' => 'required|string',
|
||||
'coupon' => 'nullable|string',
|
||||
];
|
||||
} else {
|
||||
$rules = [
|
||||
'postulation_id' => 'required|numeric',
|
||||
'supplier_id' => 'required|numeric',
|
||||
'card_id' => 'required|numeric',
|
||||
'code' => 'required|numeric',
|
||||
'device_id' => 'required|string|regex:/(^[A-Za-z0-9 ]+$)+/',
|
||||
'coupon' => 'nullable|string|regex:/(^[A-Za-z0-9 ]+$)+/',
|
||||
];
|
||||
}
|
||||
$rules = [
|
||||
'postulation_id' => 'required|numeric',
|
||||
'supplier_id' => 'required|numeric',
|
||||
'payment_intent_id' => $paymentBypass ? 'nullable|string' : 'required|string',
|
||||
'coupon' => 'nullable|string',
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
@@ -191,20 +178,12 @@ class ContractController extends Controller
|
||||
return redirect()->back()->withInput($request->all())->withErrors($validator);
|
||||
} else {
|
||||
|
||||
$user = Auth::user();
|
||||
$user = Auth::user();
|
||||
$postulation = Postulations::where('id', $request->postulation_id)->first();
|
||||
$coupon = Coupon::where('name', $request->coupon)->first();
|
||||
|
||||
if (!$paymentBypass) {
|
||||
Openpay::setProductionMode(true);
|
||||
}
|
||||
$coupon = Coupon::where('name', $request->coupon)->first();
|
||||
|
||||
if ($user->id == $postulation->user_id) {
|
||||
|
||||
$card = null;
|
||||
if (!$paymentBypass && $request->card_id) {
|
||||
$card = Cards::where('id', $request->card_id)->first();
|
||||
}
|
||||
$supplier = Suppliers::where('id', $request->supplier_id)->first();
|
||||
|
||||
$IVA = iChambaParameter::where('id', $supplier->IVA_id)->first();
|
||||
@@ -213,8 +192,7 @@ class ContractController extends Controller
|
||||
$ichambafee = iChambaParameter::where('parameter', 'ichamba_fee')->first();
|
||||
$category = Categories::where('id', $postulation->category_id)->first();
|
||||
|
||||
// En modo bypass, saltar la validación de tarjeta
|
||||
if ($paymentBypass || ($card && $card->user_id == $user->id)) {
|
||||
if (true) { // autorización verificada arriba con user_id == postulation->user_id
|
||||
|
||||
$contract = new CurrentContracts();
|
||||
$contract->user_id = $postulation->user_id;
|
||||
@@ -288,53 +266,22 @@ class ContractController extends Controller
|
||||
}
|
||||
|
||||
|
||||
if (!empty($request->card_id) && !empty($request->device_id) && !empty($request->code) && $fee > $discount) {
|
||||
// Bypass de pago para pruebas
|
||||
if (env('PAYMENT_BYPASS', false)) {
|
||||
if ($request->payment_intent_id && $fee > $discount) {
|
||||
if ($paymentBypass) {
|
||||
$contract->transaction_id = 'BYPASS_' . uniqid();
|
||||
} else {
|
||||
\Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));
|
||||
try {
|
||||
$openpay = Openpay::getInstance(config('app.openpay_id'), config('app.openpay_apikey'));
|
||||
|
||||
$customer = $openpay->customers->get($user->openpay_id);
|
||||
$charge = $customer->charges->create($chargeData);
|
||||
|
||||
|
||||
} catch (OpenpayApiTransactionError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'No se pudo procesar la transacción'
|
||||
]);
|
||||
} catch (OpenpayApiRequestError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'No se pudo procesar la operación'
|
||||
]);
|
||||
} catch (OpenpayApiConnectionError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error al conectarse a Openpay:' . $e->getMessage()
|
||||
]);
|
||||
|
||||
} catch (OpenpayApiAuthError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error al conectarse a Openpay' . $e->getMessage()
|
||||
]);
|
||||
|
||||
} catch (OpenpayApiError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error al conectarse a Openpay' . $e->getMessage()
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error: ' . $e->getMessage()
|
||||
]);
|
||||
$intent = \Stripe\PaymentIntent::retrieve($request->payment_intent_id);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['type' => 'error', 'message' => 'PaymentIntent inválido'], 422);
|
||||
}
|
||||
|
||||
$contract->transaction_id = $charge->id;
|
||||
if ($intent->status !== 'succeeded') {
|
||||
return response()->json(['type' => 'error', 'message' => 'El pago no ha sido confirmado'], 422);
|
||||
}
|
||||
|
||||
$contract->transaction_id = $intent->id;
|
||||
}
|
||||
|
||||
} else if ($coupon) {
|
||||
@@ -356,53 +303,34 @@ class ContractController extends Controller
|
||||
|
||||
Postulations::destroy($request->postulation_id);
|
||||
|
||||
//Notify the suppliers that they have been hired
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"Dirígete a la sección de postulaciones contratadas en la app para ver más detalles",
|
||||
(string) $supplier->user_id,
|
||||
null, null, null, null,
|
||||
"Proveedor: has sido contratado"
|
||||
);
|
||||
// TODO: Configurar WhatsApp cuando esté disponible
|
||||
// Whatsapp::send($supplier->user->phone, Messages\TemplateMessage::create()
|
||||
// ->name('suppplier_hired')
|
||||
// ->language('es_US')
|
||||
// ->body(Messages\Components\Body::create([
|
||||
// Messages\Components\Parameters\Text::create('Proveedor has sido contratado: dirígete a la sección de postulaciones contratadas en JobHero para ver más detalles'),
|
||||
// ])));
|
||||
try {
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"Dirígete a la sección de postulaciones contratadas en la app para ver más detalles",
|
||||
(string) $supplier->user_id,
|
||||
null, null, null, null,
|
||||
"Proveedor: has sido contratado"
|
||||
);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
//Schedule a notification for the suppliers about their appointment
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"Tienes un servicio en " . $contract->address . " hoy en 30 minutos. Dirígete a la sección de postulaciones contratados para más detalles",
|
||||
(string) $supplier->user_id,
|
||||
null, null, null,
|
||||
$delay_UTC,
|
||||
"Proveedor, no olvides tu cita de hoy"
|
||||
);
|
||||
// TODO: Configurar WhatsApp cuando esté disponible
|
||||
// Whatsapp::send($supplier->user->phone, Messages\TemplateMessage::create()
|
||||
// ->name('suppplier_appointment')
|
||||
// ->language('es_US')
|
||||
// ->body(Messages\Components\Body::create([
|
||||
// Messages\Components\Parameters\Text::create('Proveedor no olvides tu cita de hoy: Tienes un servicio en ' . $contract->address . ' hoy en 30 minutos. Dírigeta a la sección de postulaciones contratados para más detalles'),
|
||||
// ])));
|
||||
try {
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"Tienes un servicio en " . $contract->address . " hoy en 30 minutos. Dirígete a la sección de postulaciones contratados para más detalles",
|
||||
(string) $supplier->user_id,
|
||||
null, null, null,
|
||||
$delay_UTC,
|
||||
"Proveedor, no olvides tu cita de hoy"
|
||||
);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
|
||||
//Schedule a notification for the users about their appointment
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"Tienes un servicio agendado hoy en " . $contract->address . " en 30 minutos. Dirígete a la sección de contratos confirmados para más detalles",
|
||||
(string) $user->id,
|
||||
null, null, null,
|
||||
$delay_UTC,
|
||||
$user->name . ", no olvides tu cita de hoy"
|
||||
);
|
||||
// TODO: Configurar WhatsApp cuando esté disponible
|
||||
// Whatsapp::send($user->phone, Messages\TemplateMessage::create()
|
||||
// ->name('user_appointment')
|
||||
// ->language('es_US')
|
||||
// ->body(Messages\Components\Body::create([
|
||||
// Messages\Components\Parameters\Text::create($user->name . ' no olvides tu cita de hoy: Tienes un servicio agendado hoy en ' . $contract->address . ' en 30 minutos. Dírigeta a la sección de contratos confirmados para más detalles'),
|
||||
// ])));
|
||||
try {
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"Tienes un servicio agendado hoy en " . $contract->address . " en 30 minutos. Dirígete a la sección de contratos confirmados para más detalles",
|
||||
(string) $user->id,
|
||||
null, null, null,
|
||||
$delay_UTC,
|
||||
$user->name . ", no olvides tu cita de hoy"
|
||||
);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Servicio contratado exitosamente'
|
||||
@@ -483,46 +411,34 @@ class ContractController extends Controller
|
||||
|
||||
Postulations::destroy($request->postulation_id);
|
||||
|
||||
//Notify the suppliers that they have been hired
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"Dirígete a la sección de postulaciones contratadas en la app para ver más detalles",
|
||||
(string) $supplier->user_id,
|
||||
null, null, null, null,
|
||||
"Proveedor: has sido contratado"
|
||||
);
|
||||
// TODO: Configurar WhatsApp cuando esté disponible
|
||||
// Whatsapp::send($supplier->user->phone, Messages\TemplateMessage::create()
|
||||
// ->name('suppplier_hired')
|
||||
// ->language('es_US')
|
||||
// ->body(Messages\Components\Body::create([
|
||||
// Messages\Components\Parameters\Text::create('Proveedor has sido contratado: dirígete a la sección de postulaciones contratadas en JobHero para ver más detalles'),
|
||||
// ])));
|
||||
try {
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"Dirígete a la sección de postulaciones contratadas en la app para ver más detalles",
|
||||
(string) $supplier->user_id,
|
||||
null, null, null, null,
|
||||
"Proveedor: has sido contratado"
|
||||
);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
//Schedule a notification for the suppliers about their appointment
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"Tienes un servicio en " . $contract->address . " hoy en 30 minutos. Dirígete a la sección de postulaciones contratados para más detalles",
|
||||
(string) $supplier->user_id,
|
||||
null, null, null,
|
||||
$delay_UTC,
|
||||
"Proveedor, no olvides tu cita de hoy"
|
||||
);
|
||||
// TODO: Configurar WhatsApp cuando esté disponible
|
||||
// Whatsapp::send($supplier->user->phone, Messages\TemplateMessage::create()
|
||||
// ->name('suppplier_appointment')
|
||||
// ->language('es_US')
|
||||
// ->body(Messages\Components\Body::create([
|
||||
// Messages\Components\Parameters\Text::create('Proveedor no olvides tu cita de hoy: Tienes un servicio en ' . $contract->address . ' hoy en 30 minutos. Dírigeta a la sección de postulaciones contratados para más detalles'),
|
||||
// ])));
|
||||
try {
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"Tienes un servicio en " . $contract->address . " hoy en 30 minutos. Dirígete a la sección de postulaciones contratados para más detalles",
|
||||
(string) $supplier->user_id,
|
||||
null, null, null,
|
||||
$delay_UTC,
|
||||
"Proveedor, no olvides tu cita de hoy"
|
||||
);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
|
||||
//Schedule a notification for the users about their appointment
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"Tienes un servicio agendado hoy en " . $contract->address . " en 30 minutos. Dirígete a la sección de contratos confirmados para más detalles",
|
||||
(string) $user->id,
|
||||
null, null, null,
|
||||
$delay_UTC,
|
||||
$user->name . ", no olvides tu cita de hoy"
|
||||
);
|
||||
try {
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"Tienes un servicio agendado hoy en " . $contract->address . " en 30 minutos. Dirígete a la sección de contratos confirmados para más detalles",
|
||||
(string) $user->id,
|
||||
null, null, null,
|
||||
$delay_UTC,
|
||||
$user->name . ", no olvides tu cita de hoy"
|
||||
);
|
||||
} catch (\Exception $e) {}
|
||||
// TODO: Configurar WhatsApp cuando esté disponible
|
||||
// Whatsapp::send($user->phone, Messages\TemplateMessage::create()
|
||||
// ->name('user_appointment')
|
||||
@@ -643,7 +559,8 @@ class ContractController extends Controller
|
||||
|
||||
public function getcurrentcontracts(Request $request) {
|
||||
$user = Auth::user();
|
||||
$ccontracts = CurrentContracts::where('user_id', $user->id)->orderBy('created_at', 'DESC')->get();
|
||||
$ccontracts = CurrentContracts::with(['technician.user'])
|
||||
->where('user_id', $user->id)->orderBy('created_at', 'DESC')->get();
|
||||
$currentcontracts = array();
|
||||
|
||||
foreach($ccontracts as $ccontract) {
|
||||
@@ -651,6 +568,12 @@ class ContractController extends Controller
|
||||
$supplier = Suppliers::where('id', $ccontract->supplier_id)->first();
|
||||
$time_limit = Carbon::parse($ccontract->appointment);
|
||||
$day_limit = Carbon::parse($ccontract->created_at);
|
||||
$technician_name = $ccontract->technical_id
|
||||
? ($ccontract->technician->user->name ?? null)
|
||||
: ($supplier ? ($supplier->user->name ?? null) : null);
|
||||
$profile_photo = $ccontract->technical_id
|
||||
? ($ccontract->technician->user->profile_photo ?? null)
|
||||
: ($supplier ? ($supplier->user->profile_photo ?? null) : null);
|
||||
$currentcontractinfo = array(
|
||||
'id' => $ccontract->id,
|
||||
'phone' => $supplier ? ($supplier->user ? $supplier->user->phone : null) : null,
|
||||
@@ -659,6 +582,8 @@ class ContractController extends Controller
|
||||
'address' => $ccontract->address,
|
||||
'date' => $ccontract->appointment,
|
||||
'supplier' => $supplier ? $supplier->company_name : 'Proveedor no disponible',
|
||||
'technician' => $technician_name,
|
||||
'profile_photo' => $profile_photo,
|
||||
'status' => $ccontract->status_id,
|
||||
'amount' => $ccontract->amount,
|
||||
'code' => $ccontract->code,
|
||||
@@ -691,48 +616,14 @@ class ContractController extends Controller
|
||||
|
||||
$time_limit = Carbon::parse($ccontract->appointment);
|
||||
if ($time_limit->diffInHours(Carbon::now()) >= 24) {
|
||||
if($ccontract->transaction_id != 'NO APPLY') {
|
||||
if ($ccontract->transaction_id !== 'NO APPLY' && !str_starts_with($ccontract->transaction_id, 'BYPASS_')) {
|
||||
try {
|
||||
$openpay = Openpay::getInstance(config('app.openpay_id'), config('app.openpay_apikey'));
|
||||
|
||||
$refundData = array(
|
||||
'description' => 'Reembolso del contrato con id: ' . $ccontract->id . ', del usuario ' . $user->name . '. Con proveedor: ' . $supplier->id,
|
||||
);
|
||||
|
||||
$customer = $openpay->customers->get($user->openpay_id);
|
||||
$charge = $customer->charges->get($ccontract->transaction_id);
|
||||
$charge->refund($refundData);
|
||||
} catch (OpenpayApiTransactionError $e) {
|
||||
\Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));
|
||||
\Stripe\Refund::create(['payment_intent' => $ccontract->transaction_id]);
|
||||
} catch (\Stripe\Exception\ApiErrorException $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'No se pudo procesar la transacción'
|
||||
]);
|
||||
} catch (OpenpayApiRequestError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'No se pudo procesar la operación'
|
||||
]);
|
||||
} catch (OpenpayApiConnectionError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error al conectarse a Openpay:' . $e->getMessage()
|
||||
]);
|
||||
|
||||
} catch (OpenpayApiAuthError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error al conectarse a Openpay' . $e->getMessage()
|
||||
]);
|
||||
|
||||
} catch (OpenpayApiError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error al conectarse a Openpay' . $e->getMessage()
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error: ' . $e->getMessage()
|
||||
'message' => 'No se pudo procesar el reembolso: ' . $e->getMessage()
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -754,18 +645,21 @@ class ContractController extends Controller
|
||||
$fcontract->revenue = $ccontract->revenue;
|
||||
$fcontract->details = $ccontract->details;
|
||||
$fcontract->en = $ccontract->en;
|
||||
$fcontract->transaction_id = (!empty($charge->id) ? $charge->id : $ccontract->transaction_id);
|
||||
$fcontract->transaction_id = $ccontract->transaction_id;
|
||||
$fcontract->technical_id = $ccontract->technical_id;
|
||||
$fcontract->status_id = 4;
|
||||
$fcontract->save();
|
||||
|
||||
CurrentContracts::destroy($request->contract_id);
|
||||
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"El servicio en " . $fcontract->address . " el día " . substr($fcontract->appointment, 0, 10) . "ha sido cancelado. Dírigeta a la sección de servicios contratados para más detalles",
|
||||
(string) $supplier->user_id,
|
||||
null, null, null, null,
|
||||
"Proveedor: un servicio ha sido cancelado"
|
||||
);
|
||||
try {
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"El servicio en " . $fcontract->address . " el día " . substr($fcontract->appointment, 0, 10) . "ha sido cancelado. Dírigeta a la sección de servicios contratados para más detalles",
|
||||
(string) $supplier->user_id,
|
||||
null, null, null, null,
|
||||
"Proveedor: un servicio ha sido cancelado"
|
||||
);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Servicio cancelado exitosamente'
|
||||
@@ -785,17 +679,29 @@ class ContractController extends Controller
|
||||
return redirect()->back()->withInput($request->all())->withErrors($validator);
|
||||
} else {
|
||||
|
||||
$user = Auth::user();
|
||||
$supplier = $user->suppliers;
|
||||
$user = Auth::user();
|
||||
$supplier = $user->suppliers;
|
||||
$technician = null;
|
||||
|
||||
if (!$supplier) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'No tienes un perfil de proveedor registrado'
|
||||
], 400);
|
||||
$technician = Technician::where('user_id', $user->id)->first();
|
||||
if (!$technician) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'No tienes un perfil de proveedor o técnico registrado'
|
||||
], 400);
|
||||
}
|
||||
$supplier = $technician->supplier;
|
||||
}
|
||||
|
||||
$ccontract = CurrentContracts::where('code', $request->contract_pin)->where('supplier_id', $supplier->id)->first();
|
||||
$ccontract = $technician
|
||||
? CurrentContracts::where('code', $request->contract_pin)
|
||||
->where('supplier_id', $technician->supplier_id)
|
||||
->where('technical_id', $technician->id)
|
||||
->first()
|
||||
: CurrentContracts::where('code', $request->contract_pin)
|
||||
->where('supplier_id', $supplier->id)
|
||||
->first();
|
||||
|
||||
if($ccontract) {
|
||||
|
||||
@@ -819,6 +725,7 @@ class ContractController extends Controller
|
||||
$fcontract->en = $ccontract->en;
|
||||
$fcontract->coupon_id = $ccontract->coupon_id;
|
||||
$fcontract->transaction_id = $ccontract->transaction_id;
|
||||
$fcontract->technical_id = $ccontract->technical_id;
|
||||
$fcontract->status_id = 3;
|
||||
$fcontract->score = 5;
|
||||
$fcontract->save();
|
||||
@@ -836,12 +743,14 @@ class ContractController extends Controller
|
||||
$payment->status_id = null;
|
||||
$payment->save();
|
||||
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"El servicio en " . $fcontract->address . " el día " . substr($fcontract->appointment, 0, 10) . " ha sido iniciado. Dírigeta a la sección de servicios contratados para más detalles",
|
||||
(string) $fcontract->user_id,
|
||||
null, null, null, null,
|
||||
"Usuario: el proveedor ha iniciado el servicio"
|
||||
);
|
||||
try {
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"El servicio en " . $fcontract->address . " el día " . substr($fcontract->appointment, 0, 10) . " ha sido iniciado. Dírigeta a la sección de servicios contratados para más detalles",
|
||||
(string) $fcontract->user_id,
|
||||
null, null, null, null,
|
||||
"Usuario: el proveedor ha iniciado el servicio"
|
||||
);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Servicio iniciado exitosamente'
|
||||
@@ -971,14 +880,17 @@ class ContractController extends Controller
|
||||
|
||||
public function getfinishedcontracts(Request $request) {
|
||||
$user = Auth::user();
|
||||
$fcontracts = FinishedContracts::where('user_id', $user->id)->orderBy('created_at', 'DESC')->get();
|
||||
$fcontracts = FinishedContracts::with(['technician.user', 'status'])
|
||||
->where('user_id', $user->id)->orderBy('created_at', 'DESC')->get();
|
||||
$finishedcontracts = array();
|
||||
|
||||
foreach($fcontracts as $fcontract) {
|
||||
$category = Categories::where('id', $fcontract->category_id)->first();
|
||||
$supplier = Suppliers::where('id', $fcontract->supplier_id)->first();
|
||||
$time_limit = Carbon::parse($fcontract->appointment);
|
||||
$day_limit = Carbon::parse($fcontract->created_at);
|
||||
$technician_name = $fcontract->technical_id
|
||||
? ($fcontract->technician->user->name ?? null)
|
||||
: ($supplier ? ($supplier->user->name ?? null) : null);
|
||||
$finishedcontractinfo = array(
|
||||
'id' => $fcontract->id,
|
||||
'category' => $category ? $category->name : null,
|
||||
@@ -987,6 +899,7 @@ class ContractController extends Controller
|
||||
'date' => $fcontract->appointment,
|
||||
'date_difference' => $time_limit->diff(Carbon::now(), false)->days,
|
||||
'supplier' => $supplier ? $supplier->company_name : 'Proveedor no disponible',
|
||||
'technician' => $technician_name,
|
||||
'amount' => $fcontract->amount,
|
||||
'scored' => $fcontract->scored_at,
|
||||
'parent' => $fcontract->parent_contract_id,
|
||||
|
||||
@@ -137,12 +137,14 @@ class NoHomeController extends Controller
|
||||
if (Carbon::now()->diffInMinutes($contract->appointment, false) < 10) {
|
||||
return response()->json($contract);
|
||||
} else {
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"El proveedor para el servicio en " . $contract->address . " ha llegado. Dírigeta a la sección de contratos confirmados para más detalles",
|
||||
(string) $client->id,
|
||||
null, null, null, null,
|
||||
$client->name . ", tu proveedor del servicio ha llegado"
|
||||
);
|
||||
try {
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"El proveedor para el servicio en " . $contract->address . " ha llegado. Dírigeta a la sección de contratos confirmados para más detalles",
|
||||
(string) $client->id,
|
||||
null, null, null, null,
|
||||
$client->name . ", tu proveedor del servicio ha llegado"
|
||||
);
|
||||
} catch (\Exception $e) {}
|
||||
return response()->json([
|
||||
//'message' => 'Por favor espere a los 10 minutos de tolerancia de la hora acordada'
|
||||
'message' => 'wait'
|
||||
@@ -227,12 +229,14 @@ class NoHomeController extends Controller
|
||||
'message' => 'Ausencia registrada con éxito, nos comunicaremos con usted por correo electrónico en caso de alguna circunstancia'
|
||||
]);
|
||||
} else {
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"El proveedor para el servicio en " . $ccontract->address . " ha llegado. Dírigeta a la sección de contratos confirmados para más detalles",
|
||||
(string) $client->id,
|
||||
null, null, null, null,
|
||||
$client->name . ", tu proveedor del servicio ha llegado"
|
||||
);
|
||||
try {
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"El proveedor para el servicio en " . $ccontract->address . " ha llegado. Dírigeta a la sección de contratos confirmados para más detalles",
|
||||
(string) $client->id,
|
||||
null, null, null, null,
|
||||
$client->name . ", tu proveedor del servicio ha llegado"
|
||||
);
|
||||
} catch (\Exception $e) {}
|
||||
return response()->json([
|
||||
'order' => 'wait',
|
||||
'message' => 'Por favor espere a los 10 minutos de tolerancia de la hora acordada'
|
||||
|
||||
34
app/Http/Controllers/PaymentBatchController.php
Normal file
34
app/Http/Controllers/PaymentBatchController.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\PaymentBatch;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PaymentBatchController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$batches = PaymentBatch::with('user')
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate(15);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return view('payment-batches.index', compact('batches'));
|
||||
}
|
||||
|
||||
return view('payment-batches.ajax', compact('batches'));
|
||||
}
|
||||
|
||||
public function download($id)
|
||||
{
|
||||
$batch = PaymentBatch::findOrFail($id);
|
||||
$absolutePath = storage_path('app/' . $batch->file_path);
|
||||
|
||||
if (!file_exists($absolutePath)) {
|
||||
return redirect('payment-batches')->with('error', 'El archivo ya no está disponible en el servidor.');
|
||||
}
|
||||
|
||||
return response()->download($absolutePath, $batch->file_name);
|
||||
}
|
||||
}
|
||||
@@ -10,14 +10,12 @@ use App\Models\User;
|
||||
use App\Models\Suppliers;
|
||||
use App\Models\Payments;
|
||||
use App\Models\FinishedContracts;
|
||||
use App\Models\Cards;
|
||||
use Openpay;
|
||||
use Exception;
|
||||
use OpenpayApiError;
|
||||
use OpenpayApiAuthError;
|
||||
use OpenpayApiRequestError;
|
||||
use OpenpayApiConnectionError;
|
||||
use OpenpayApiTransactionError;
|
||||
use App\Models\PaymentBatch;
|
||||
use Stripe\Stripe;
|
||||
use Stripe\Customer;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class PaymentController extends Controller
|
||||
{
|
||||
@@ -33,7 +31,7 @@ class PaymentController extends Controller
|
||||
if ($request->has('date_to')) $request->session()->put('pay_date_to', $dateTo);
|
||||
|
||||
$contracts = FinishedContracts::with(['suppliers.user', 'suppliers.banks'])
|
||||
->where('status_id', 3)
|
||||
->whereIn('status_id', [3, 9])
|
||||
->where('paid', false)
|
||||
->where('transaction_id', '!=', 'NO APPLY')
|
||||
->when($dateFrom, fn($q) => $q->whereDate('appointment', '>=', $dateFrom))
|
||||
@@ -93,327 +91,158 @@ class PaymentController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function cardsindex(Request $request)
|
||||
public function intent(Request $request)
|
||||
{
|
||||
//
|
||||
$request->session()->put('search', $request
|
||||
->has('search') ? strip_tags($request->get('search')) : ($request->session()
|
||||
->has('search') ? strip_tags($request->session()->get('search')) : ''));
|
||||
|
||||
$request->session()->put('field', $request
|
||||
->has('field') ? strip_tags($request->get('field')) : ($request->session()
|
||||
->has('field') ? strip_tags($request->session()->get('field')) : 'id'));
|
||||
|
||||
$request->session()->put('sort', $request
|
||||
->has('sort') ? strip_tags($request->get('sort')) : ($request->session()
|
||||
->has('sort') ? strip_tags($request->session()->get('sort')) : 'asc'));
|
||||
|
||||
//$headers = $request->get('header') != '' ? $request->get('header') : -1;
|
||||
|
||||
$cards= new Cards();
|
||||
$cards = $cards->where('id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
|
||||
->orwhere('token', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
|
||||
->orderBy(strip_tags($request->session()->get('field')), strip_tags($request->session()->get('sort')))
|
||||
->paginate(10);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return view('cards.index', compact('cards'));
|
||||
} else {
|
||||
return view('cards.ajax', compact('cards'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$credit_card = Cards::where('id', $id)->first();
|
||||
$user = User::where('id', $credit_card->user_id)->first();
|
||||
Openpay::setProductionMode(true);
|
||||
|
||||
try {
|
||||
$openpay = Openpay::getInstance(config('app.openpay_id'), config('app.openpay_apikey'));
|
||||
$customer = $openpay->customers->get($user->openpay_id);
|
||||
$card = $customer->cards->get($credit_card->token);
|
||||
$card->delete();
|
||||
} catch (OpenpayApiTransactionError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error en la transacción'
|
||||
]);
|
||||
} catch (OpenpayApiRequestError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error en los datos requeridos'
|
||||
]);
|
||||
} catch (OpenpayApiConnectionError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
|
||||
]);
|
||||
} catch (OpenpayApiAuthError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
|
||||
]);
|
||||
|
||||
} catch (OpenpayApiError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error: ' . $e->getMessage()
|
||||
]);
|
||||
$validator = Validator::make($request->all(), [
|
||||
'supplier_id' => 'required|numeric',
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
return response()->json($validator->errors(), 422);
|
||||
}
|
||||
|
||||
Cards::destroy($id);
|
||||
return redirect('cards');
|
||||
}
|
||||
$user = Auth::user();
|
||||
$supplier = Suppliers::find($request->supplier_id);
|
||||
|
||||
public function addcard(Request $request)
|
||||
{
|
||||
$rules = [
|
||||
'token' => 'required|string|regex:/(^[A-Za-z0-9 ]+$)+/',
|
||||
'device_id' => 'required|string|regex:/(^[A-Za-z0-9 ]+$)+/',
|
||||
];
|
||||
if (!$supplier) {
|
||||
return response()->json(['message' => 'Proveedor no encontrado'], 404);
|
||||
}
|
||||
|
||||
$validator = Validator::make($request->all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->withInput($request->all())->withErrors($validator);
|
||||
}
|
||||
Stripe::setApiKey(env('STRIPE_SECRET'));
|
||||
|
||||
$user = $request->user();
|
||||
Openpay::setProductionMode(true);
|
||||
if (!$user->stripe_customer_id) {
|
||||
$customer = Customer::create([
|
||||
'email' => $user->email,
|
||||
'name' => $user->name,
|
||||
]);
|
||||
$user->stripe_customer_id = $customer->id;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
if ($user->openpay_id == null) {
|
||||
try {
|
||||
$openpay = Openpay::getInstance(config('app.openpay_id'), config('app.openpay_apikey'));
|
||||
$customerData = array(
|
||||
'external_id' => $user->id,
|
||||
'name' => $user->name,
|
||||
'email' => $user->email,
|
||||
$amount = max((int) $supplier->minimun_fee, 150);
|
||||
|
||||
try {
|
||||
$ephemeralKey = \Stripe\EphemeralKey::create(
|
||||
['customer' => $user->stripe_customer_id],
|
||||
['stripe_version' => \Stripe\Stripe::$apiVersion]
|
||||
);
|
||||
$customer = $openpay->customers->add($customerData);
|
||||
} catch (OpenpayApiTransactionError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'No se pudo procesar la transacción'
|
||||
]);
|
||||
} catch (OpenpayApiRequestError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'No se pudo procesar la operación'
|
||||
]);
|
||||
} catch (OpenpayApiConnectionError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
|
||||
]);
|
||||
|
||||
} catch (OpenpayApiAuthError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
|
||||
$intent = \Stripe\PaymentIntent::create([
|
||||
'amount' => $amount * 100,
|
||||
'currency' => env('STRIPE_CURRENCY', 'mxn'),
|
||||
'customer' => $user->stripe_customer_id,
|
||||
'automatic_payment_methods' => ['enabled' => true],
|
||||
]);
|
||||
|
||||
} catch (OpenpayApiError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error: ' . $e->getMessage()
|
||||
]);
|
||||
}
|
||||
|
||||
$user->openpay_id = $customer->id;
|
||||
$user->save();
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
|
||||
$cardDataRequest = array(
|
||||
'token_id' => $request->token,
|
||||
'device_session_id' => $request->device_id
|
||||
);
|
||||
|
||||
try {
|
||||
$openpay = Openpay::getInstance(config('app.openpay_id'), config('app.openpay_apikey'));
|
||||
$customer = $openpay->customers->get($user->openpay_id);
|
||||
$card = $customer->cards->add($cardDataRequest);
|
||||
|
||||
} catch (OpenpayApiTransactionError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'No se pudo procesar la transacción'
|
||||
'payment_intent_id' => $intent->id,
|
||||
'client_secret' => $intent->client_secret,
|
||||
'customer' => $user->stripe_customer_id,
|
||||
'ephemeral_key' => $ephemeralKey->secret,
|
||||
]);
|
||||
} catch (OpenpayApiRequestError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'No se pudo procesar la operación'
|
||||
]);
|
||||
} catch (OpenpayApiConnectionError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
|
||||
]);
|
||||
|
||||
} catch (OpenpayApiAuthError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
|
||||
]);
|
||||
|
||||
} catch (OpenpayApiError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error: ' . $e->getMessage()
|
||||
]);
|
||||
}
|
||||
|
||||
$card = new Cards();
|
||||
|
||||
$card->user_id = $user->id;
|
||||
$card->token = $request->token;
|
||||
|
||||
$card->save();
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Tarjeta guardada exitosamente'
|
||||
]);
|
||||
}
|
||||
|
||||
public function deletecard(Request $request)
|
||||
{
|
||||
$rules = [
|
||||
'card_id' => 'required|numeric',
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->withInput($request->all())->withErrors($validator);
|
||||
}
|
||||
|
||||
$user = $request->user();
|
||||
$credit_card = Cards::where('id', $request->card_id)->first();
|
||||
Openpay::setProductionMode(true);
|
||||
|
||||
|
||||
if ($credit_card->user_id == $user->id) {
|
||||
try {
|
||||
$openpay = Openpay::getInstance(config('app.openpay_id'), config('app.openpay_apikey'));
|
||||
$customer = $openpay->customers->get($user->openpay_id);
|
||||
$card = $customer->cards->get($credit_card->token);
|
||||
$card->delete();
|
||||
} catch (OpenpayApiTransactionError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'No se pudo procesar la transacción'
|
||||
]);
|
||||
} catch (OpenpayApiRequestError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'No se pudo procesar la operación'
|
||||
]);
|
||||
} catch (OpenpayApiConnectionError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
|
||||
]);
|
||||
|
||||
} catch (OpenpayApiAuthError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
|
||||
]);
|
||||
|
||||
} catch (OpenpayApiError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error: ' . $e->getMessage()
|
||||
]);
|
||||
}
|
||||
|
||||
Cards::destroy($request->card_id);
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Tarjeta eliminada exitosamente'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function getcards(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
Openpay::setProductionMode(true);
|
||||
$user = Auth::user();
|
||||
$cards = Cards::where('user_id', $user->id)->get()->map(fn($c) => [
|
||||
'id' => $c->id,
|
||||
'payment_method_id' => $c->stripe_pm_id,
|
||||
'brand' => $c->brand,
|
||||
'last4' => $c->last4,
|
||||
'exp_month' => $c->exp_month,
|
||||
'exp_year' => $c->exp_year,
|
||||
]);
|
||||
|
||||
if ($user->openpay_id) {
|
||||
try {
|
||||
$openpay = Openpay::getInstance(config('app.openpay_id'), config('app.openpay_apikey'));
|
||||
$customer = $openpay->customers->get($user->openpay_id);
|
||||
} catch (OpenpayApiTransactionError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'No se pudo procesar la transacción'
|
||||
]);
|
||||
} catch (OpenpayApiRequestError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'No se pudo procesar la operación'
|
||||
]);
|
||||
} catch (OpenpayApiConnectionError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
|
||||
]);
|
||||
return response()->json($cards);
|
||||
}
|
||||
|
||||
} catch (OpenpayApiAuthError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
|
||||
]);
|
||||
public function generate(Request $request)
|
||||
{
|
||||
$dateFrom = $request->input('date_from', '');
|
||||
$dateTo = $request->input('date_to', '');
|
||||
|
||||
} catch (OpenpayApiError $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
return response()->json([
|
||||
'type' => 'error',
|
||||
'message' => 'Error: ' . $e->getMessage()
|
||||
]);
|
||||
$contracts = FinishedContracts::with(['suppliers.user', 'suppliers.banks'])
|
||||
->whereIn('status_id', [3, 9])
|
||||
->where('paid', false)
|
||||
->where('transaction_id', '!=', 'NO APPLY')
|
||||
->when($dateFrom, fn($q) => $q->whereDate('appointment', '>=', $dateFrom))
|
||||
->when($dateTo, fn($q) => $q->whereDate('appointment', '<=', $dateTo))
|
||||
->get();
|
||||
|
||||
if ($contracts->isEmpty()) {
|
||||
return redirect('payments')->with('warning', 'No hay contratos pendientes de pago con los filtros seleccionados.');
|
||||
}
|
||||
|
||||
$cards = Cards::where('user_id', $user->id)->get();
|
||||
$contractIds = $contracts->pluck('id');
|
||||
|
||||
$cardsinfo = array();
|
||||
$grouped = $contracts->groupBy('supplier_id')->map(function ($group) {
|
||||
$first = $group->first();
|
||||
return [
|
||||
'suppliers' => $first->suppliers,
|
||||
'contract_count' => $group->count(),
|
||||
'total_amount' => $group->sum('amount'),
|
||||
'total_revenue' => $group->sum('revenue'),
|
||||
'total_iva' => $group->sum('IVA'),
|
||||
'total_isr' => $group->sum('ISR'),
|
||||
'total_fee' => $group->sum('ichamba_fee'),
|
||||
];
|
||||
})->values();
|
||||
|
||||
foreach ($cards as $credit_card) {
|
||||
$card = $customer->cards->get($credit_card->token);
|
||||
$cardinfo = array(
|
||||
'id' => $credit_card->id,
|
||||
'brand' => $card->brand,
|
||||
'card_number' => $card->card_number,
|
||||
);
|
||||
$cardsinfo[] = $cardinfo;
|
||||
// Generar Excel
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$sheet->setTitle('Pagos');
|
||||
|
||||
$headers = ['Proveedor', 'Email', 'RFC / CURP', 'CLABE', 'Banco', 'Contratos', 'Monto Total', 'Utilidad', 'Ret. IVA', 'Ret. ISR', 'Ret. JobHero'];
|
||||
foreach ($headers as $i => $header) {
|
||||
$sheet->setCellValueByColumnAndRow($i + 1, 1, $header);
|
||||
}
|
||||
return response()->json($cardsinfo);
|
||||
}
|
||||
|
||||
foreach ($grouped as $idx => $data) {
|
||||
$row = $idx + 2;
|
||||
$supplier = $data['suppliers'];
|
||||
$sheet->setCellValueByColumnAndRow(1, $row, optional($supplier)->company_name ?? '');
|
||||
$sheet->setCellValueByColumnAndRow(2, $row, optional(optional($supplier)->user)->email ?? '');
|
||||
$sheet->setCellValueByColumnAndRow(3, $row, optional($supplier)->RFC ?: (optional($supplier)->CURP ?? ''));
|
||||
$sheet->setCellValueByColumnAndRow(4, $row, optional($supplier)->clabe ?? '');
|
||||
$sheet->setCellValueByColumnAndRow(5, $row, optional(optional($supplier)->banks)->name ?? '');
|
||||
$sheet->setCellValueByColumnAndRow(6, $row, $data['contract_count']);
|
||||
$sheet->setCellValueByColumnAndRow(7, $row, $data['total_amount']);
|
||||
$sheet->setCellValueByColumnAndRow(8, $row, $data['total_revenue']);
|
||||
$sheet->setCellValueByColumnAndRow(9, $row, $data['total_iva']);
|
||||
$sheet->setCellValueByColumnAndRow(10, $row, $data['total_isr']);
|
||||
$sheet->setCellValueByColumnAndRow(11, $row, $data['total_fee']);
|
||||
}
|
||||
|
||||
$now = now();
|
||||
$fileName = 'pagos_' . $now->format('Y-m-d_H-i-s') . '.xlsx';
|
||||
$relativePath = 'payment-batches/' . $fileName;
|
||||
$absolutePath = storage_path('app/' . $relativePath);
|
||||
|
||||
if (!is_dir(storage_path('app/payment-batches'))) {
|
||||
mkdir(storage_path('app/payment-batches'), 0755, true);
|
||||
}
|
||||
|
||||
$writer = new Xlsx($spreadsheet);
|
||||
$writer->save($absolutePath);
|
||||
|
||||
PaymentBatch::create([
|
||||
'file_name' => $fileName,
|
||||
'file_path' => $relativePath,
|
||||
'generated_by' => Auth::id(),
|
||||
'date_from' => $dateFrom ?: null,
|
||||
'date_to' => $dateTo ?: null,
|
||||
]);
|
||||
|
||||
FinishedContracts::whereIn('id', $contractIds)->update([
|
||||
'paid' => true,
|
||||
'paid_at' => $now,
|
||||
]);
|
||||
|
||||
return response()->download($absolutePath, $fileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ class PostulationController extends Controller
|
||||
$geometry = new Point($request->lat, $request->lng);
|
||||
$category = Categories::where('name', strip_tags($request->category))->orwhere('en_name', strip_tags($request->category))->first();
|
||||
|
||||
$distance = 0.5;
|
||||
$distance = 5000; // metros (5 km)
|
||||
$suppliers = Suppliers::withinDistanceTo('location', $geometry, $distance)->get();
|
||||
|
||||
if ($suppliers != '[]') {
|
||||
@@ -129,21 +129,25 @@ class PostulationController extends Controller
|
||||
$postulation->details = preg_replace('/\d+/', '', strip_tags($request->details));
|
||||
$postulation->save();
|
||||
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"Coméntele al Ing. que hay una postulación",
|
||||
"128",
|
||||
null, null, null, null,
|
||||
"Admin: hay nueva postulación"
|
||||
);
|
||||
try {
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"Coméntele al Ing. que hay una postulación",
|
||||
"128",
|
||||
null, null, null, null,
|
||||
"Admin: hay nueva postulación"
|
||||
);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
foreach ($suppliers as $supplier) {
|
||||
if (in_array($category->id, $supplier->categories->pluck('id')->toArray())) {
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"Dirígete a la sección de postulaciones en la app para ver más detalles",
|
||||
(string) $supplier->user_id,
|
||||
null, null, null, null,
|
||||
"Proveedor: hay nueva postulación"
|
||||
);
|
||||
try {
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"Dirígete a la sección de postulaciones en la app para ver más detalles",
|
||||
(string) $supplier->user_id,
|
||||
null, null, null, null,
|
||||
"Proveedor: hay nueva postulación"
|
||||
);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
// TODO: Configurar WhatsApp cuando esté disponible
|
||||
// Whatsapp::send($supplier->user->phone, Messages\TemplateMessage::create()
|
||||
@@ -156,28 +160,30 @@ class PostulationController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
$minutes = intval(substr(substr($request->setdate, 14), 0, 2) + 15);
|
||||
$hours = intval(substr(substr($request->setdate, 11), 0, 2) + 1);
|
||||
$minutes = intval(substr(substr($request->sethour, 14), 0, 2) + 15);
|
||||
$hours = intval(substr(substr($request->sethour, 11), 0, 2) + 1);
|
||||
|
||||
if ($minutes > 59) {
|
||||
if ($hours > 23){
|
||||
$delay_msg = Carbon::now()->addDays(1)->toDateString() . ' ' . ($hours - 24) . ':' . ($minutes - 60) . substr(substr($request->setdate, 16), 0, 3);
|
||||
$delay_msg = Carbon::now()->addDays(1)->toDateString() . ' ' . ($hours - 24) . ':' . ($minutes - 60) . substr(substr($request->sethour, 16), 0, 3);
|
||||
} else {
|
||||
$delay_msg = substr($request->sethour, 0, 10) . ' ' . $hours . ':' . ($minutes - 60) . substr(substr($request->setdate, 16), 0, 3);
|
||||
$delay_msg = substr($request->sethour, 0, 10) . ' ' . $hours . ':' . ($minutes - 60) . substr(substr($request->sethour, 16), 0, 3);
|
||||
}
|
||||
} else {
|
||||
$delay_msg = substr($request->sethour, 0, 10) . ' ' . $hours . ':' . $minutes . substr(substr($request->setdate, 16), 0, 3);
|
||||
$delay_msg = substr($request->sethour, 0, 10) . ' ' . $hours . ':' . $minutes . substr(substr($request->sethour, 16), 0, 3);
|
||||
}
|
||||
|
||||
$delay_UTC = Carbon::now()->addMinutes(15)->toString();
|
||||
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"Dirígete a la sección de contratos en la app para ver más detalles",
|
||||
(string) $user->id,
|
||||
null, null, null,
|
||||
$delay_UTC,
|
||||
"Búsqueda Finalizada"
|
||||
);
|
||||
try {
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"Dirígete a la sección de contratos en la app para ver más detalles",
|
||||
(string) $user->id,
|
||||
null, null, null,
|
||||
$delay_UTC,
|
||||
"Búsqueda Finalizada"
|
||||
);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Servicio solicitado, espere a que un proveedor se postule'
|
||||
@@ -217,12 +223,14 @@ class PostulationController extends Controller
|
||||
if ($time_limit > 0) {
|
||||
if (in_array($postulation->category_id, $supplier->categories->pluck('id')->toArray())) {
|
||||
if($supplier->membership == 1) {
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"Dirígete a la sección de contratos en la app para ver más detalles",
|
||||
(string) $postulation->user_id,
|
||||
null, null, null, null,
|
||||
"Un proveedor certificado se ha postulado"
|
||||
);
|
||||
try {
|
||||
OneSignal::sendNotificationToExternalUser(
|
||||
"Dirígete a la sección de contratos en la app para ver más detalles",
|
||||
(string) $postulation->user_id,
|
||||
null, null, null, null,
|
||||
"Un proveedor certificado se ha postulado"
|
||||
);
|
||||
} catch (\Exception $e) {}
|
||||
}
|
||||
// TODO: Configurar WhatsApp cuando esté disponible
|
||||
// Whatsapp::send($postulation->user->phone, Messages\TemplateMessage::create()
|
||||
@@ -282,19 +290,24 @@ class PostulationController extends Controller
|
||||
], 400);
|
||||
}
|
||||
|
||||
$postulations = FinishedContracts::where('supplier_id', $user->suppliers->id)->orderBy('created_at', 'DESC')->get();
|
||||
$supplier = $user->suppliers;
|
||||
$postulations = FinishedContracts::with(['technician.user'])
|
||||
->where('supplier_id', $supplier->id)->orderBy('created_at', 'DESC')->get();
|
||||
$finishedpostulations = array();
|
||||
|
||||
foreach($postulations as $postulation) {
|
||||
$time_limit = Carbon::parse($postulation->appointment);
|
||||
$category = Categories::where('id', $postulation->category_id)->first();
|
||||
$technician = $postulation->technical_id
|
||||
? ($postulation->technician->user->name ?? null)
|
||||
: ($supplier->user->name ?? null);
|
||||
$finishedpostulationinfo = array(
|
||||
'id' => $postulation->id,
|
||||
'category' => $category->name,
|
||||
'en_category' => $category->en_name,
|
||||
'address' => $postulation->address,
|
||||
'date' => $postulation->appointment,
|
||||
'amount' => $postulation->amount
|
||||
'amount' => $postulation->amount,
|
||||
'technician' => $technician
|
||||
);
|
||||
$finishedpostulations[] = $finishedpostulationinfo;
|
||||
}
|
||||
|
||||
@@ -2,111 +2,78 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Report;
|
||||
use App\Models\ReportComment;
|
||||
use App\Models\FinishedContracts;
|
||||
use App\Models\Suppliers;
|
||||
use App\Models\NoHome;
|
||||
use OneSignal;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class ReportCommentController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(Request $request, $id, $contract_id)
|
||||
public function index(Request $request, $id)
|
||||
{
|
||||
//
|
||||
$request->session()->put('search', $request
|
||||
->has('search') ? strip_tags($request->get('search')) : ($request->session()
|
||||
->has('search') ? strip_tags($request->session()->get('search')) : ''));
|
||||
$report = Report::find($id);
|
||||
$contract = FinishedContracts::with(['user', 'suppliers.user', 'categories', 'status'])->find($report->contract_id);
|
||||
$nohome = NoHome::where('contract_id', $contract->id)->first();
|
||||
$comments = ReportComment::with('user')
|
||||
->where('report_id', $id)
|
||||
->orderBy('created_at', 'asc')
|
||||
->paginate(50);
|
||||
|
||||
$request->session()->put('field', $request
|
||||
->has('field') ? strip_tags($request->get('field')) : ($request->session()
|
||||
->has('field') ? strip_tags($request->session()->get('field')) : 'id'));
|
||||
|
||||
$request->session()->put('sort', $request
|
||||
->has('sort') ? strip_tags($request->get('sort')) : ($request->session()
|
||||
->has('sort') ? strip_tags($request->session()->get('sort')) : 'asc'));
|
||||
|
||||
//$headers = $request->get('header') != '' ? $request->get('header') : -1;
|
||||
|
||||
$contract = FinishedContracts::where('id', $contract_id)->first();
|
||||
$nohome = NoHome::where('contract_id', $contract_id)->first();
|
||||
$comments = new ReportComment();
|
||||
$comments = $comments->where('report_id', $id)
|
||||
->orderBy(strip_tags($request->session()->get('field')), strip_tags($request->session()->get('sort')))
|
||||
->paginate(10);
|
||||
|
||||
if ($request->isMethod('get'))
|
||||
return view('reports.comments', compact('comments', 'contract', 'nohome'));
|
||||
return view('reports.comments', compact('comments', 'contract', 'nohome', 'report'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
public function store(Request $request, $id)
|
||||
{
|
||||
//
|
||||
$validator = Validator::make($request->all(), [
|
||||
'comment' => 'required|string',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->withErrors($validator);
|
||||
}
|
||||
|
||||
$comment = new ReportComment();
|
||||
$comment->report_id = $id;
|
||||
$comment->user_id = Auth::id();
|
||||
$comment->comment = strip_tags($request->comment);
|
||||
$comment->save();
|
||||
|
||||
$report = Report::find($id);
|
||||
$contract = FinishedContracts::find($report->contract_id);
|
||||
$supplier = Suppliers::find($contract->supplier_id);
|
||||
|
||||
$recipients = array_filter([
|
||||
$contract->user_id,
|
||||
$supplier->user_id ?? null,
|
||||
]);
|
||||
|
||||
foreach ($recipients as $recipientId) {
|
||||
try {
|
||||
OneSignal::sendNotificationCustom([
|
||||
'include_external_user_ids' => [(string) $recipientId],
|
||||
'contents' => [
|
||||
'es' => 'Moderador: ' . $comment->comment,
|
||||
'en' => 'Moderator: ' . $comment->comment,
|
||||
],
|
||||
'headings' => [
|
||||
'es' => 'Nueva actividad en tu reporte',
|
||||
'en' => 'New activity on your report',
|
||||
],
|
||||
]);
|
||||
} catch (\Exception $e) {}
|
||||
}
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
public function destroy($id, $comment_id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\ReportComment $reportComment
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(ReportComment $reportComment)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\ReportComment $reportComment
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(ReportComment $reportComment)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\ReportComment $reportComment
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, ReportComment $reportComment)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\ReportComment $reportComment
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id, $contract_id)
|
||||
{
|
||||
//
|
||||
ReportComment::destroy($id);
|
||||
return redirect('reports/comments/'.$id.'/'.$contract_id);
|
||||
ReportComment::destroy($comment_id);
|
||||
return redirect('reports/' . $id . '/comments');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@ use App\Models\FinishedContracts;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use OneSignal;
|
||||
use Stripe\Stripe;
|
||||
use Stripe\Refund;
|
||||
|
||||
class ReportController extends Controller
|
||||
{
|
||||
@@ -89,26 +92,46 @@ class ReportController extends Controller
|
||||
*/
|
||||
public function veredict(Request $request, $id)
|
||||
{
|
||||
//
|
||||
if ($request->isMethod('get'))
|
||||
return view('reports.veredict', ['report' => Report::find($id)]);
|
||||
return view('reports.veredict', ['report' => Report::with('finishedcontracts')->find($id)]);
|
||||
|
||||
$rules = [
|
||||
'veredict' => 'required|string',
|
||||
'veredict' => 'required|string',
|
||||
'contract_status' => 'nullable|in:8,9',
|
||||
];
|
||||
|
||||
$messages = [
|
||||
'veredict.required' => 'Se requiere un veredicto',
|
||||
'veredict.required' => 'Se requiere un veredicto',
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(), $rules, $messages);
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->withInput($request->all())->withErrors($validator);
|
||||
return redirect()->back()->withInput($request->all())->withErrors($validator);
|
||||
}
|
||||
|
||||
$report = Report::find($id);
|
||||
$report = Report::with('finishedcontracts')->find($id);
|
||||
$report->veredict = strip_tags($request->veredict);
|
||||
$coupon->save();
|
||||
$report->save();
|
||||
|
||||
if ($request->filled('contract_status')) {
|
||||
$contract = $report->finishedcontracts;
|
||||
$newStatus = (int) $request->contract_status;
|
||||
|
||||
if ($newStatus === 8) {
|
||||
$tid = $contract->transaction_id ?? null;
|
||||
if ($tid && $tid !== 'NO APPLY' && !str_starts_with($tid, 'BYPASS_')) {
|
||||
try {
|
||||
Stripe::setApiKey(env('STRIPE_SECRET'));
|
||||
Refund::create(['payment_intent' => $tid]);
|
||||
} catch (\Exception $e) {
|
||||
// reembolso fallido: se registra pero no bloquea el flujo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$contract->status_id = $newStatus;
|
||||
$contract->save();
|
||||
}
|
||||
|
||||
return redirect('reports');
|
||||
}
|
||||
@@ -138,6 +161,176 @@ class ReportController extends Controller
|
||||
return redirect('reports');
|
||||
}
|
||||
|
||||
public function getcomments(Request $request, $id)
|
||||
{
|
||||
$user = Auth::user();
|
||||
$report = Report::with('finishedcontracts.suppliers')->find($id);
|
||||
|
||||
if (!$report) {
|
||||
return response()->json(['message' => 'Reporte no encontrado'], 404);
|
||||
}
|
||||
|
||||
$contract = $report->finishedcontracts;
|
||||
$supplierUserId = $contract->suppliers->user_id ?? null;
|
||||
|
||||
if ($user->id !== $contract->user_id && $user->id !== $supplierUserId) {
|
||||
return response()->json(['message' => 'No autorizado'], 403);
|
||||
}
|
||||
|
||||
$comments = ReportComment::with('user')
|
||||
->where('report_id', $id)
|
||||
->orderBy('created_at', 'asc')
|
||||
->get()
|
||||
->map(function ($c) use ($contract, $supplierUserId) {
|
||||
$isSupplier = $c->user_id === $supplierUserId;
|
||||
$isClient = $c->user_id === $contract->user_id;
|
||||
return [
|
||||
'id' => $c->id,
|
||||
'sender_id' => $c->user_id,
|
||||
'sender_name' => $isSupplier
|
||||
? ($contract->suppliers->company_name ?? null)
|
||||
: ($c->user->name ?? null),
|
||||
'role_id' => $c->user->role_id ?? null,
|
||||
'sender_type' => !$isClient && !$isSupplier ? 'moderator' : null,
|
||||
'comment' => $c->comment,
|
||||
'created_at' => $c->created_at,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($comments);
|
||||
}
|
||||
|
||||
public function storecomment(Request $request, $id)
|
||||
{
|
||||
$validator = Validator::make($request->all(), ['comment' => 'required|string']);
|
||||
if ($validator->fails()) {
|
||||
return response()->json($validator->errors(), 422);
|
||||
}
|
||||
|
||||
$user = Auth::user();
|
||||
$report = Report::with('finishedcontracts.suppliers')->find($id);
|
||||
|
||||
if (!$report) {
|
||||
return response()->json(['message' => 'Reporte no encontrado'], 404);
|
||||
}
|
||||
|
||||
$contract = $report->finishedcontracts;
|
||||
$supplierUserId = $contract->suppliers->user_id ?? null;
|
||||
|
||||
if ($user->id !== $contract->user_id && $user->id !== $supplierUserId) {
|
||||
return response()->json(['message' => 'No autorizado'], 403);
|
||||
}
|
||||
|
||||
$comment = new ReportComment();
|
||||
$comment->report_id = $id;
|
||||
$comment->user_id = $user->id;
|
||||
$comment->comment = strip_tags($request->comment);
|
||||
$comment->save();
|
||||
|
||||
$supplierUserId = $contract->suppliers->user_id ?? null;
|
||||
$isSupplier = $user->id === $supplierUserId;
|
||||
$isClient = $user->id === $contract->user_id;
|
||||
|
||||
$recipientId = $isClient ? $supplierUserId : $contract->user_id;
|
||||
if ($recipientId) {
|
||||
try {
|
||||
OneSignal::sendNotificationCustom([
|
||||
'include_external_user_ids' => [(string) $recipientId],
|
||||
'contents' => [
|
||||
'es' => $user->name . ': ' . $comment->comment,
|
||||
'en' => $user->name . ': ' . $comment->comment,
|
||||
],
|
||||
'headings' => [
|
||||
'es' => 'Nueva actividad en tu reporte',
|
||||
'en' => 'New activity on your report',
|
||||
],
|
||||
]);
|
||||
} catch (\Exception $e) {}
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'id' => $comment->id,
|
||||
'sender_id' => $user->id,
|
||||
'sender_name' => $isSupplier ? ($contract->suppliers->company_name ?? null) : $user->name,
|
||||
'role_id' => $user->role_id,
|
||||
'sender_type' => !$isClient && !$isSupplier ? 'moderator' : null,
|
||||
'comment' => $comment->comment,
|
||||
'created_at' => $comment->created_at,
|
||||
], 201);
|
||||
}
|
||||
|
||||
public function getsupplierreports(Request $request)
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if (!$user->suppliers) {
|
||||
return response()->json(['success' => false, 'message' => 'No tienes un perfil de proveedor registrado'], 400);
|
||||
}
|
||||
|
||||
$contractIds = FinishedContracts::where('supplier_id', $user->suppliers->id)->pluck('id');
|
||||
|
||||
$reports = Report::with([
|
||||
'finishedcontracts.suppliers.user',
|
||||
'finishedcontracts.categories',
|
||||
'finishedcontracts.technician.user',
|
||||
])
|
||||
->whereIn('contract_id', $contractIds)
|
||||
->orderBy('created_at', 'desc')
|
||||
->get();
|
||||
|
||||
$data = $reports->map(function ($report) {
|
||||
$contract = $report->finishedcontracts;
|
||||
$technician = $contract->technical_id
|
||||
? ($contract->technician->user->name ?? null)
|
||||
: ($contract->suppliers->user->name ?? null);
|
||||
return [
|
||||
'id' => $report->id,
|
||||
'technician' => $technician,
|
||||
'company' => $contract->suppliers->company_name ?? null,
|
||||
'category' => $contract->categories->name ?? null,
|
||||
'en_category' => $contract->categories->en_name ?? null,
|
||||
'appointment' => $contract->appointment,
|
||||
'address' => $contract->address,
|
||||
'amount' => $contract->amount,
|
||||
'veredict' => $report->veredict,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
public function getreports(Request $request)
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
$contractIds = FinishedContracts::where('user_id', $user->id)->pluck('id');
|
||||
|
||||
$reports = Report::with([
|
||||
'finishedcontracts.suppliers.user',
|
||||
'finishedcontracts.categories',
|
||||
])
|
||||
->whereIn('contract_id', $contractIds)
|
||||
->orderBy('created_at', 'desc')
|
||||
->get();
|
||||
|
||||
$data = $reports->map(function ($report) {
|
||||
$contract = $report->finishedcontracts;
|
||||
return [
|
||||
'id' => $report->id,
|
||||
'supplier' => $contract->suppliers->user->name ?? null,
|
||||
'company' => $contract->suppliers->company_name ?? null,
|
||||
'category' => $contract->categories->name ?? null,
|
||||
'en_category' => $contract->categories->en_name ?? null,
|
||||
'appointment' => $contract->appointment,
|
||||
'address' => $contract->address,
|
||||
'amount' => $contract->amount,
|
||||
'veredict' => $report->veredict,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
public function report(Request $request) {
|
||||
|
||||
$rules = [
|
||||
|
||||
@@ -1237,7 +1237,7 @@ class SupplierController extends Controller
|
||||
], 400);
|
||||
}
|
||||
|
||||
$distance = 0.5;
|
||||
$distance = 5000; // metros (5 km)
|
||||
$postulations = Postulations::withinDistanceTo('location', $supplier->location, $distance)->orderBy('created_at', 'DESC')->get();
|
||||
|
||||
$postulationsinfo = array();
|
||||
@@ -1280,12 +1280,19 @@ class SupplierController extends Controller
|
||||
], 400);
|
||||
}
|
||||
|
||||
$contracts = CurrentContracts::where('supplier_id', $supplier->id)->orderBy('created_at', 'DESC')->get();
|
||||
$contracts = CurrentContracts::with(['technician.user'])
|
||||
->where('supplier_id', $supplier->id)->orderBy('created_at', 'DESC')->get();
|
||||
|
||||
$contractsinfo = array();
|
||||
|
||||
foreach ($contracts as $contract) {
|
||||
$category = Categories::where('id', $contract->category_id)->first();
|
||||
$technician = $contract->technical_id
|
||||
? ($contract->technician->user->name ?? null)
|
||||
: ($supplier->user->name ?? null);
|
||||
$profile_photo = $contract->technical_id
|
||||
? ($contract->technician->user->profile_photo ?? null)
|
||||
: ($supplier->user->profile_photo ?? null);
|
||||
$contractinfo = array(
|
||||
'id' => $contract->id,
|
||||
'phone' => $contract->user->phone,
|
||||
@@ -1297,7 +1304,9 @@ class SupplierController extends Controller
|
||||
'lat' => $contract->location->getLat(),
|
||||
'lng' => $contract->location->getLng(),
|
||||
'amount' => $contract->amount,
|
||||
'details' => $contract->details
|
||||
'details' => $contract->details,
|
||||
'technician' => $technician,
|
||||
'profile_photo' => $profile_photo
|
||||
);
|
||||
$contractsinfo[] = $contractinfo;
|
||||
}
|
||||
|
||||
192
app/Http/Controllers/TechnicianController.php
Normal file
192
app/Http/Controllers/TechnicianController.php
Normal file
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Technician;
|
||||
use App\Models\User;
|
||||
use App\Models\CurrentContracts;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class TechnicianController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$user = Auth::user();
|
||||
$supplier = $user->suppliers;
|
||||
|
||||
if (!$supplier) {
|
||||
return response()->json(['message' => 'No tienes un perfil de proveedor'], 400);
|
||||
}
|
||||
|
||||
$technicians = Technician::with('user')
|
||||
->where('supplier_id', $supplier->id)
|
||||
->get()
|
||||
->map(fn($t) => [
|
||||
'id' => $t->id,
|
||||
'user_id' => $t->user_id,
|
||||
'name' => $t->user->name ?? null,
|
||||
'email' => $t->user->email ?? null,
|
||||
'phone' => $t->user->phone ?? null,
|
||||
]);
|
||||
|
||||
return response()->json($technicians);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'user_id' => 'required|numeric|exists:users,id',
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
return response()->json($validator->errors(), 422);
|
||||
}
|
||||
|
||||
$user = Auth::user();
|
||||
$supplier = $user->suppliers;
|
||||
|
||||
if (!$supplier) {
|
||||
return response()->json(['message' => 'No tienes un perfil de proveedor'], 400);
|
||||
}
|
||||
|
||||
$targetUser = User::find($request->user_id);
|
||||
|
||||
if ($targetUser->id === $user->id) {
|
||||
return response()->json(['message' => 'No puedes agregarte a ti mismo como técnico'], 422);
|
||||
}
|
||||
|
||||
$exists = Technician::where('user_id', $request->user_id)
|
||||
->where('supplier_id', $supplier->id)
|
||||
->exists();
|
||||
|
||||
if ($exists) {
|
||||
return response()->json(['message' => 'Este usuario ya es técnico de tu empresa'], 422);
|
||||
}
|
||||
|
||||
$technician = Technician::create([
|
||||
'user_id' => $request->user_id,
|
||||
'supplier_id' => $supplier->id,
|
||||
]);
|
||||
|
||||
$targetUser->role_id = 8;
|
||||
$targetUser->save();
|
||||
|
||||
return response()->json([
|
||||
'id' => $technician->id,
|
||||
'user_id' => $technician->user_id,
|
||||
'name' => $targetUser->name,
|
||||
'email' => $targetUser->email,
|
||||
'phone' => $targetUser->phone,
|
||||
], 201);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$user = Auth::user();
|
||||
$supplier = $user->suppliers;
|
||||
|
||||
if (!$supplier) {
|
||||
return response()->json(['message' => 'No tienes un perfil de proveedor'], 400);
|
||||
}
|
||||
|
||||
$technician = Technician::where('id', $id)
|
||||
->where('supplier_id', $supplier->id)
|
||||
->first();
|
||||
|
||||
if (!$technician) {
|
||||
return response()->json(['message' => 'Técnico no encontrado'], 404);
|
||||
}
|
||||
|
||||
// Revertir role a "Usuario" solo si no pertenece a otro proveedor
|
||||
$otherSuppliers = Technician::where('user_id', $technician->user_id)
|
||||
->where('supplier_id', '!=', $supplier->id)
|
||||
->exists();
|
||||
|
||||
if (!$otherSuppliers) {
|
||||
$targetUser = User::find($technician->user_id);
|
||||
if ($targetUser && $targetUser->role_id === 8) {
|
||||
$targetUser->role_id = 1;
|
||||
$targetUser->save();
|
||||
}
|
||||
}
|
||||
|
||||
$technician->delete();
|
||||
|
||||
return response()->json(['message' => 'Técnico eliminado exitosamente']);
|
||||
}
|
||||
|
||||
public function find(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'email' => 'required|email',
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
return response()->json($validator->errors(), 422);
|
||||
}
|
||||
|
||||
$user = Auth::user();
|
||||
$supplier = $user->suppliers;
|
||||
|
||||
if (!$supplier) {
|
||||
return response()->json(['message' => 'No tienes un perfil de proveedor'], 400);
|
||||
}
|
||||
|
||||
$targetUser = User::where('email', $request->email)->first();
|
||||
|
||||
if (!$targetUser) {
|
||||
return response()->json(['message' => 'Usuario no encontrado'], 404);
|
||||
}
|
||||
|
||||
$alreadyInTeam = Technician::where('user_id', $targetUser->id)
|
||||
->where('supplier_id', $supplier->id)
|
||||
->exists();
|
||||
|
||||
return response()->json([
|
||||
'id' => $targetUser->id,
|
||||
'name' => $targetUser->name,
|
||||
'email' => $targetUser->email,
|
||||
'phone' => $targetUser->phone,
|
||||
'already_in_team' => $alreadyInTeam,
|
||||
]);
|
||||
}
|
||||
|
||||
public function assign(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'contract_id' => 'required|numeric|exists:current_contracts,id',
|
||||
'technician_id' => 'nullable|numeric|exists:technicians,id',
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
return response()->json($validator->errors(), 422);
|
||||
}
|
||||
|
||||
$user = Auth::user();
|
||||
$supplier = $user->suppliers;
|
||||
|
||||
if (!$supplier) {
|
||||
return response()->json(['message' => 'No tienes un perfil de proveedor'], 400);
|
||||
}
|
||||
|
||||
$contract = CurrentContracts::find($request->contract_id);
|
||||
|
||||
if ($contract->supplier_id !== $supplier->id) {
|
||||
return response()->json(['message' => 'No autorizado'], 403);
|
||||
}
|
||||
|
||||
if ($request->technician_id) {
|
||||
$technician = Technician::where('id', $request->technician_id)
|
||||
->where('supplier_id', $supplier->id)
|
||||
->first();
|
||||
|
||||
if (!$technician) {
|
||||
return response()->json(['message' => 'El técnico no pertenece a tu empresa'], 422);
|
||||
}
|
||||
}
|
||||
|
||||
$contract->technical_id = $request->technician_id ?? null;
|
||||
$contract->save();
|
||||
|
||||
return response()->json(['message' => 'Técnico asignado exitosamente']);
|
||||
}
|
||||
}
|
||||
@@ -107,7 +107,6 @@ class UserController extends Controller
|
||||
'name' => 'required|string',
|
||||
'email' => 'required|string|email',
|
||||
'role' => 'required|numeric',
|
||||
'openpay_id' => 'string|nullable',
|
||||
];
|
||||
|
||||
$messages = [
|
||||
@@ -125,9 +124,6 @@ class UserController extends Controller
|
||||
$user->name = strip_tags($request->name);
|
||||
$user->email = $request->email;
|
||||
$user->role_id = $request->role;
|
||||
if ($request->openpay_id == "null" OR $request->openpay_id == null){
|
||||
$user->openpay_id = null;
|
||||
}
|
||||
$user->save();
|
||||
|
||||
return redirect('users');
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Models\Categories;
|
||||
use App\Models\Suppliers;
|
||||
use App\Models\Coupon;
|
||||
use App\Models\Status;
|
||||
use App\Models\Technician;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use TarfinLabs\LaravelSpatial\Casts\LocationCast;
|
||||
use TarfinLabs\LaravelSpatial\Traits\HasSpatial;
|
||||
@@ -30,6 +31,7 @@ class CurrentContracts extends Model
|
||||
'coupon_id',
|
||||
'transaction_id',
|
||||
'status_id',
|
||||
'technical_id',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
@@ -61,4 +63,9 @@ class CurrentContracts extends Model
|
||||
return $this->belongsTo(Status::class);
|
||||
}
|
||||
|
||||
public function technician()
|
||||
{
|
||||
return $this->belongsTo(Technician::class, 'technical_id');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ use App\Models\Status;
|
||||
use App\Models\Report;
|
||||
use App\Models\Payments;
|
||||
use App\Models\NoHome;
|
||||
use App\Models\Technician;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use TarfinLabs\LaravelSpatial\Casts\LocationCast;
|
||||
use TarfinLabs\LaravelSpatial\Traits\HasSpatial;
|
||||
@@ -34,6 +35,7 @@ class FinishedContracts extends Model
|
||||
'transaction_id',
|
||||
'score',
|
||||
'status_id',
|
||||
'technical_id',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
@@ -80,4 +82,9 @@ class FinishedContracts extends Model
|
||||
return $this->hasOne(NoHome::class);
|
||||
}
|
||||
|
||||
public function technician()
|
||||
{
|
||||
return $this->belongsTo(Technician::class, 'technical_id');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
22
app/Models/PaymentBatch.php
Normal file
22
app/Models/PaymentBatch.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PaymentBatch extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'file_name',
|
||||
'file_path',
|
||||
'generated_by',
|
||||
'date_from',
|
||||
'date_to',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'generated_by');
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ class Report extends Model
|
||||
|
||||
public function finishedcontracts()
|
||||
{
|
||||
return $this->belongsTo(FinishedContracts::class);
|
||||
return $this->belongsTo(FinishedContracts::class, 'contract_id');
|
||||
}
|
||||
|
||||
public function user()
|
||||
|
||||
@@ -10,6 +10,7 @@ use App\Models\Postulations;
|
||||
use App\Models\FinishedContracts;
|
||||
use App\Models\CurrentContracts;
|
||||
use App\Models\Payments;
|
||||
use App\Models\Technician;
|
||||
use TarfinLabs\LaravelSpatial\Casts\LocationCast;
|
||||
use TarfinLabs\LaravelSpatial\Traits\HasSpatial;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -73,6 +74,11 @@ class Suppliers extends Model
|
||||
return $this->hasMany(FinishedContracts::class);
|
||||
}
|
||||
|
||||
public function technicians()
|
||||
{
|
||||
return $this->hasMany(Technician::class, 'supplier_id');
|
||||
}
|
||||
|
||||
public function ichambaparameters()
|
||||
{
|
||||
return $this->belongsTo(iChambaParameter::class);
|
||||
|
||||
11
app/Models/Cards.php → app/Models/Technician.php
Executable file → Normal file
11
app/Models/Cards.php → app/Models/Technician.php
Executable file → Normal file
@@ -3,16 +3,23 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Suppliers;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Cards extends Model
|
||||
class Technician extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'token',
|
||||
'supplier_id',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function supplier()
|
||||
{
|
||||
return $this->belongsTo(Suppliers::class, 'supplier_id');
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ namespace App\Models;
|
||||
|
||||
use App\Models\Role;
|
||||
use App\Models\LinkedSocialAccount;
|
||||
use App\Models\Cards;
|
||||
use App\Models\Suppliers;
|
||||
use App\Models\Postulations;
|
||||
use App\Models\Report;
|
||||
@@ -27,10 +26,9 @@ class User extends Authenticatable
|
||||
'profile_photo',
|
||||
'role_id',
|
||||
'social_id',
|
||||
'openpay_id',
|
||||
'stripe_customer_id',
|
||||
'password',
|
||||
'phone',
|
||||
'openpay_id',
|
||||
'phone_verified_at'
|
||||
];
|
||||
protected $hidden = [
|
||||
@@ -54,11 +52,6 @@ class User extends Authenticatable
|
||||
return $this->hasMany(LinkedSocialAccount::class);
|
||||
}
|
||||
|
||||
public function cards()
|
||||
{
|
||||
return $this->hasMany(Cards::class);
|
||||
}
|
||||
|
||||
public function suppliers()
|
||||
{
|
||||
return $this->hasOne(Suppliers::class);
|
||||
|
||||
@@ -17,15 +17,17 @@ class PushNotificationService
|
||||
*/
|
||||
public function sendToUser(int $userId, string $message, string $heading = 'JobHero', array $data = [])
|
||||
{
|
||||
return OneSignal::sendNotificationToExternalUser(
|
||||
$message,
|
||||
(string) $userId,
|
||||
null,
|
||||
$data ?: null,
|
||||
null,
|
||||
null,
|
||||
$heading
|
||||
);
|
||||
try {
|
||||
return OneSignal::sendNotificationToExternalUser(
|
||||
$message,
|
||||
(string) $userId,
|
||||
null,
|
||||
$data ?: null,
|
||||
null,
|
||||
null,
|
||||
$heading
|
||||
);
|
||||
} catch (\Exception $e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,15 +60,17 @@ class PushNotificationService
|
||||
*/
|
||||
public function sendScheduledToUser(int $userId, string $message, string $sendAt, string $heading = 'JobHero', array $data = [])
|
||||
{
|
||||
return OneSignal::sendNotificationToExternalUser(
|
||||
$message,
|
||||
(string) $userId,
|
||||
null,
|
||||
$data ?: null,
|
||||
null,
|
||||
$sendAt,
|
||||
$heading
|
||||
);
|
||||
try {
|
||||
return OneSignal::sendNotificationToExternalUser(
|
||||
$message,
|
||||
(string) $userId,
|
||||
null,
|
||||
$data ?: null,
|
||||
null,
|
||||
$sendAt,
|
||||
$heading
|
||||
);
|
||||
} catch (\Exception $e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +84,7 @@ class PushNotificationService
|
||||
*/
|
||||
public function sendToRole(int $roleId, string $message, string $heading = 'JobHero', array $data = [])
|
||||
{
|
||||
return OneSignal::sendNotificationUsingTags(
|
||||
try { return OneSignal::sendNotificationUsingTags(
|
||||
$message,
|
||||
[
|
||||
['field' => 'tag', 'key' => 'iChamba_Role', 'relation' => '=', 'value' => (string) $roleId]
|
||||
@@ -107,7 +111,7 @@ class PushNotificationService
|
||||
null,
|
||||
null,
|
||||
$data
|
||||
);
|
||||
); } catch (\Exception $e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
"openpay/sdk": "^2.0",
|
||||
"spatie/laravel-google-cloud-storage": "^2.3",
|
||||
"spatie/laravel-html": "^3.0",
|
||||
"phpoffice/phpspreadsheet": "^2.0",
|
||||
"stripe/stripe-php": "^20.2",
|
||||
"tarfin-labs/laravel-spatial": "^3.0",
|
||||
"timehunter/laravel-google-recaptcha-v3": "^2.4"
|
||||
},
|
||||
|
||||
431
composer.lock
generated
431
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "c61511f0eed8a14cd184f0bae9104e5e",
|
||||
"content-hash": "36319ee9cf7a1e9c627e9e9d19baf6e6",
|
||||
"packages": [
|
||||
{
|
||||
"name": "berkayk/onesignal-laravel",
|
||||
@@ -398,6 +398,82 @@
|
||||
],
|
||||
"time": "2024-02-09T16:56:22+00:00"
|
||||
},
|
||||
{
|
||||
"name": "composer/pcre",
|
||||
"version": "3.4.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/composer/pcre.git",
|
||||
"reference": "d5a341b3fb61f3001970940afb1d332968a183ed"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/composer/pcre/zipball/d5a341b3fb61f3001970940afb1d332968a183ed",
|
||||
"reference": "d5a341b3fb61f3001970940afb1d332968a183ed",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.4 || ^8.0"
|
||||
},
|
||||
"conflict": {
|
||||
"phpstan/phpstan": "<2.2.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan/phpstan": "^2",
|
||||
"phpstan/phpstan-deprecation-rules": "^2",
|
||||
"phpstan/phpstan-strict-rules": "^2",
|
||||
"phpunit/phpunit": "^9"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"phpstan": {
|
||||
"includes": [
|
||||
"extension.neon"
|
||||
]
|
||||
},
|
||||
"branch-alias": {
|
||||
"dev-main": "3.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Composer\\Pcre\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jordi Boggiano",
|
||||
"email": "j.boggiano@seld.be",
|
||||
"homepage": "http://seld.be"
|
||||
}
|
||||
],
|
||||
"description": "PCRE wrapping library that offers type-safe preg_* replacements.",
|
||||
"keywords": [
|
||||
"PCRE",
|
||||
"preg",
|
||||
"regex",
|
||||
"regular expression"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/composer/pcre/issues",
|
||||
"source": "https://github.com/composer/pcre/tree/3.4.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://packagist.com",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/composer",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2026-06-07T11:47:49+00:00"
|
||||
},
|
||||
{
|
||||
"name": "cuyz/valinor",
|
||||
"version": "2.4.0",
|
||||
@@ -4249,6 +4325,191 @@
|
||||
],
|
||||
"time": "2026-03-08T20:05:35+00:00"
|
||||
},
|
||||
{
|
||||
"name": "maennchen/zipstream-php",
|
||||
"version": "3.2.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/maennchen/ZipStream-PHP.git",
|
||||
"reference": "77bebeb4c6c340bb3c11c843b2cffd8bbfde4d5e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/77bebeb4c6c340bb3c11c843b2cffd8bbfde4d5e",
|
||||
"reference": "77bebeb4c6c340bb3c11c843b2cffd8bbfde4d5e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-mbstring": "*",
|
||||
"ext-zlib": "*",
|
||||
"php-64bit": "^8.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"brianium/paratest": "^7.7",
|
||||
"ext-zip": "*",
|
||||
"friendsofphp/php-cs-fixer": "^3.86",
|
||||
"guzzlehttp/guzzle": "^7.5",
|
||||
"mikey179/vfsstream": "^1.6",
|
||||
"php-coveralls/php-coveralls": "^2.5",
|
||||
"phpunit/phpunit": "^12.0",
|
||||
"vimeo/psalm": "^6.0"
|
||||
},
|
||||
"suggest": {
|
||||
"guzzlehttp/psr7": "^2.4",
|
||||
"psr/http-message": "^2.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"ZipStream\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Paul Duncan",
|
||||
"email": "pabs@pablotron.org"
|
||||
},
|
||||
{
|
||||
"name": "Jonatan Männchen",
|
||||
"email": "jonatan@maennchen.ch"
|
||||
},
|
||||
{
|
||||
"name": "Jesse Donat",
|
||||
"email": "donatj@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "András Kolesár",
|
||||
"email": "kolesar@kolesar.hu"
|
||||
}
|
||||
],
|
||||
"description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.",
|
||||
"keywords": [
|
||||
"stream",
|
||||
"zip"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/maennchen/ZipStream-PHP/issues",
|
||||
"source": "https://github.com/maennchen/ZipStream-PHP/tree/3.2.2"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/maennchen",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2026-04-11T18:38:28+00:00"
|
||||
},
|
||||
{
|
||||
"name": "markbaker/complex",
|
||||
"version": "3.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/MarkBaker/PHPComplex.git",
|
||||
"reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
|
||||
"reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
|
||||
"phpcompatibility/php-compatibility": "^9.3",
|
||||
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
|
||||
"squizlabs/php_codesniffer": "^3.7"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Complex\\": "classes/src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Mark Baker",
|
||||
"email": "mark@lange.demon.co.uk"
|
||||
}
|
||||
],
|
||||
"description": "PHP Class for working with complex numbers",
|
||||
"homepage": "https://github.com/MarkBaker/PHPComplex",
|
||||
"keywords": [
|
||||
"complex",
|
||||
"mathematics"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/MarkBaker/PHPComplex/issues",
|
||||
"source": "https://github.com/MarkBaker/PHPComplex/tree/3.0.2"
|
||||
},
|
||||
"time": "2022-12-06T16:21:08+00:00"
|
||||
},
|
||||
{
|
||||
"name": "markbaker/matrix",
|
||||
"version": "3.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/MarkBaker/PHPMatrix.git",
|
||||
"reference": "728434227fe21be27ff6d86621a1b13107a2562c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/728434227fe21be27ff6d86621a1b13107a2562c",
|
||||
"reference": "728434227fe21be27ff6d86621a1b13107a2562c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
|
||||
"phpcompatibility/php-compatibility": "^9.3",
|
||||
"phpdocumentor/phpdocumentor": "2.*",
|
||||
"phploc/phploc": "^4.0",
|
||||
"phpmd/phpmd": "2.*",
|
||||
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
|
||||
"sebastian/phpcpd": "^4.0",
|
||||
"squizlabs/php_codesniffer": "^3.7"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Matrix\\": "classes/src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Mark Baker",
|
||||
"email": "mark@demon-angel.eu"
|
||||
}
|
||||
],
|
||||
"description": "PHP Class for working with matrices",
|
||||
"homepage": "https://github.com/MarkBaker/PHPMatrix",
|
||||
"keywords": [
|
||||
"mathematics",
|
||||
"matrix",
|
||||
"vector"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/MarkBaker/PHPMatrix/issues",
|
||||
"source": "https://github.com/MarkBaker/PHPMatrix/tree/3.0.1"
|
||||
},
|
||||
"time": "2022-12-02T22:17:43+00:00"
|
||||
},
|
||||
{
|
||||
"name": "mercadopago/dx-php",
|
||||
"version": "3.10.0",
|
||||
@@ -5115,6 +5376,112 @@
|
||||
},
|
||||
"time": "2024-10-02T11:20:13+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpoffice/phpspreadsheet",
|
||||
"version": "2.4.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
|
||||
"reference": "0bbef382b7d9c1dbda10c8113d564ff9159a7e79"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/0bbef382b7d9c1dbda10c8113d564ff9159a7e79",
|
||||
"reference": "0bbef382b7d9c1dbda10c8113d564ff9159a7e79",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"composer/pcre": "^1 || ^2 || ^3",
|
||||
"ext-ctype": "*",
|
||||
"ext-dom": "*",
|
||||
"ext-fileinfo": "*",
|
||||
"ext-gd": "*",
|
||||
"ext-iconv": "*",
|
||||
"ext-libxml": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-simplexml": "*",
|
||||
"ext-xml": "*",
|
||||
"ext-xmlreader": "*",
|
||||
"ext-xmlwriter": "*",
|
||||
"ext-zip": "*",
|
||||
"ext-zlib": "*",
|
||||
"maennchen/zipstream-php": "^2.1 || ^3.0",
|
||||
"markbaker/complex": "^3.0",
|
||||
"markbaker/matrix": "^3.0",
|
||||
"php": ">=8.1.0 <8.6.0",
|
||||
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "dev-main",
|
||||
"dompdf/dompdf": "^2.0 || ^3.0",
|
||||
"friendsofphp/php-cs-fixer": "^3.2",
|
||||
"mitoteam/jpgraph": "^10.5",
|
||||
"mpdf/mpdf": "^8.1.1",
|
||||
"phpcompatibility/php-compatibility": "^9.3",
|
||||
"phpstan/phpstan": "^1.1",
|
||||
"phpstan/phpstan-phpunit": "^1.0",
|
||||
"phpunit/phpunit": "^9.6 || ^10.5",
|
||||
"squizlabs/php_codesniffer": "^3.7",
|
||||
"tecnickcom/tcpdf": "^6.5"
|
||||
},
|
||||
"suggest": {
|
||||
"dompdf/dompdf": "Option for rendering PDF with PDF Writer",
|
||||
"ext-intl": "PHP Internationalization Functions, required for NumberFormatter Wizard",
|
||||
"mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
|
||||
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
|
||||
"tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Maarten Balliauw",
|
||||
"homepage": "https://blog.maartenballiauw.be"
|
||||
},
|
||||
{
|
||||
"name": "Mark Baker",
|
||||
"homepage": "https://markbakeruk.net"
|
||||
},
|
||||
{
|
||||
"name": "Franck Lefevre",
|
||||
"homepage": "https://rootslabs.net"
|
||||
},
|
||||
{
|
||||
"name": "Erik Tilt"
|
||||
},
|
||||
{
|
||||
"name": "Adrien Crivelli"
|
||||
},
|
||||
{
|
||||
"name": "Owen Leibman"
|
||||
}
|
||||
],
|
||||
"description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
|
||||
"homepage": "https://github.com/PHPOffice/PhpSpreadsheet",
|
||||
"keywords": [
|
||||
"OpenXML",
|
||||
"excel",
|
||||
"gnumeric",
|
||||
"ods",
|
||||
"php",
|
||||
"spreadsheet",
|
||||
"xls",
|
||||
"xlsx"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues",
|
||||
"source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/2.4.6"
|
||||
},
|
||||
"time": "2026-06-07T02:31:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpoption/phpoption",
|
||||
"version": "1.9.5",
|
||||
@@ -6365,6 +6732,68 @@
|
||||
],
|
||||
"time": "2026-02-22T09:05:56+00:00"
|
||||
},
|
||||
{
|
||||
"name": "stripe/stripe-php",
|
||||
"version": "v20.2.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/stripe/stripe-php.git",
|
||||
"reference": "c628cfa0b3de4ef5110b2c2bfbf881a33a52fdd5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/stripe/stripe-php/zipball/c628cfa0b3de4ef5110b2c2bfbf881a33a52fdd5",
|
||||
"reference": "c628cfa0b3de4ef5110b2c2bfbf881a33a52fdd5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-curl": "*",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"php": ">=7.2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "3.94.0",
|
||||
"phpstan/phpstan": "^1.2",
|
||||
"phpunit/phpunit": "^8.0 || ^9.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"lib/version_check.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Stripe\\": "lib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Stripe and contributors",
|
||||
"homepage": "https://github.com/stripe/stripe-php/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Stripe PHP Library",
|
||||
"homepage": "https://stripe.com/",
|
||||
"keywords": [
|
||||
"api",
|
||||
"payment processing",
|
||||
"stripe"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/stripe/stripe-php/issues",
|
||||
"source": "https://github.com/stripe/stripe-php/tree/v20.2.1"
|
||||
},
|
||||
"time": "2026-06-12T22:41:56+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/cache",
|
||||
"version": "v8.1.0",
|
||||
|
||||
@@ -20,7 +20,7 @@ class CreateUsersTable extends Migration
|
||||
$table->string('profile_photo')->nullable();
|
||||
$table->BigInteger('role_id')->unsigned()->nullable();
|
||||
$table->string('social_id')->unique()->nullable();
|
||||
$table->string('openpay_id')->unique()->nullable();
|
||||
$table->string('stripe_customer_id')->unique()->nullable();
|
||||
$table->string('phone')->unique()->nullable();
|
||||
$table->timestamp('phone_verified_at')->nullable();
|
||||
$table->string('password')->nullable();
|
||||
|
||||
@@ -16,7 +16,11 @@ class CreateCardsTable extends Migration
|
||||
Schema::create('cards', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->unsignedBigInteger('user_id');
|
||||
$table->string('token');
|
||||
$table->string('stripe_pm_id')->unique();
|
||||
$table->string('brand');
|
||||
$table->string('last4', 4);
|
||||
$table->unsignedTinyInteger('exp_month');
|
||||
$table->unsignedSmallInteger('exp_year');
|
||||
$table->timestamps();
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
});
|
||||
|
||||
@@ -36,7 +36,9 @@ class CreateFinishedcontractsTable extends Migration
|
||||
$table->unsignedBigInteger('parent_contract_id')->nullable();
|
||||
$table->Integer('score')->nullable();
|
||||
$table->timestamp('scored_at')->nullable();
|
||||
$table->unsignedBigInteger('technical_id')->nullable();
|
||||
$table->boolean('paid')->default(false);
|
||||
$table->timestamp('paid_at')->nullable();
|
||||
$table->timestamps();
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('set null');
|
||||
$table->foreign('supplier_id')->references('id')->on('suppliers')->onDelete('set null');
|
||||
|
||||
@@ -34,6 +34,7 @@ class CreateCurrentContractsTable extends Migration
|
||||
$table->unsignedBigInteger('status_id')->nullable()->default('1');
|
||||
$table->BigInteger('code')->nullable();
|
||||
$table->unsignedBigInteger('parent_contract_id')->nullable();
|
||||
$table->unsignedBigInteger('technical_id')->nullable();
|
||||
$table->timestamps();
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('set null');
|
||||
$table->foreign('supplier_id')->references('id')->on('suppliers')->onDelete('set null');
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreatePaymentBatchesTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('payment_batches', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('file_name');
|
||||
$table->string('file_path');
|
||||
$table->unsignedBigInteger('generated_by')->nullable();
|
||||
$table->date('date_from')->nullable();
|
||||
$table->date('date_to')->nullable();
|
||||
$table->timestamps();
|
||||
$table->foreign('generated_by')->references('id')->on('users')->onDelete('set null');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('payment_batches');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateTechniciansTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('technicians', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->unsignedBigInteger('user_id');
|
||||
$table->unsignedBigInteger('supplier_id');
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'supplier_id']);
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->foreign('supplier_id')->references('id')->on('suppliers')->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::table('finished_contracts', function (Blueprint $table) {
|
||||
$table->foreign('technical_id')->references('id')->on('technicians')->onDelete('set null');
|
||||
});
|
||||
|
||||
Schema::table('current_contracts', function (Blueprint $table) {
|
||||
$table->foreign('technical_id')->references('id')->on('technicians')->onDelete('set null');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('finished_contracts', function (Blueprint $table) {
|
||||
$table->dropForeign(['technical_id']);
|
||||
});
|
||||
|
||||
Schema::table('current_contracts', function (Blueprint $table) {
|
||||
$table->dropForeign(['technical_id']);
|
||||
});
|
||||
|
||||
Schema::dropIfExists('technicians');
|
||||
}
|
||||
}
|
||||
27
database/migrations/2026_06_22_000001_drop_cards_table.php
Normal file
27
database/migrations/2026_06_22_000001_drop_cards_table.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::dropIfExists('cards');
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::create('cards', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('user_id');
|
||||
$table->string('stripe_pm_id')->nullable();
|
||||
$table->string('brand')->nullable();
|
||||
$table->string('last4')->nullable();
|
||||
$table->unsignedTinyInteger('exp_month')->nullable();
|
||||
$table->unsignedSmallInteger('exp_year')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -44,6 +44,10 @@ class DatabaseSeeder extends Seeder
|
||||
'name' => 'SuperAdmin',
|
||||
]);
|
||||
|
||||
DB::table('roles')->insert([
|
||||
'name' => 'Técnico',
|
||||
]);
|
||||
|
||||
DB::table('users')->insert([
|
||||
'name' => 'Admin',
|
||||
'email' => 'torch2196@gmail.com',
|
||||
@@ -102,6 +106,10 @@ class DatabaseSeeder extends Seeder
|
||||
'en_name' => 'canceled',
|
||||
]);
|
||||
DB::table('statuses')->insert([
|
||||
'name' => 'ausente',
|
||||
'en_name' => 'absent',
|
||||
]);
|
||||
DB::table('statuses')->insert([
|
||||
'name' => 'fuera de casa',
|
||||
'en_name' => 'no home',
|
||||
]);
|
||||
@@ -110,9 +118,14 @@ class DatabaseSeeder extends Seeder
|
||||
'en_name' => 'reported',
|
||||
]);
|
||||
DB::table('statuses')->insert([
|
||||
'name' => 'ausente',
|
||||
'en_name' => 'absent',
|
||||
'name' => 'devuelto al cliente',
|
||||
'en_name' => 'returned to client',
|
||||
]);
|
||||
DB::table('statuses')->insert([
|
||||
'name' => 'disptuta terminada',
|
||||
'en_name' => 'complain ended',
|
||||
]);
|
||||
|
||||
|
||||
$this->call([
|
||||
BanksSeeder::class,
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="col-md-8 offset-md-2">
|
||||
<h1>{{isset($bank)?'Editar':'Nuevo'}} Banco</h1>
|
||||
<hr>
|
||||
@if(isset($bank))
|
||||
{!! Form::model($bank,['method'=>'put','id'=>'frm']) !!}
|
||||
@else
|
||||
{!! Form::open(['id'=>'frm']) !!}
|
||||
@endif
|
||||
<div class="form-group row required">
|
||||
{!! Form::label("code","Código",["class"=>"col-form-label col-md-3 col-lg-2"]) !!}
|
||||
<div class="col-md-8">
|
||||
{!! Form::number("code",null,["class"=>"form-control".($errors->has('code')?" is-invalid":""),"autofocus",'placeholder'=>'Código del banco']) !!}
|
||||
<span id="error-name" class="invalid-feedback"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row required">
|
||||
{!! Form::label("name","Banco",["class"=>"col-form-label col-md-3 col-lg-2"]) !!}
|
||||
<div class="col-md-8">
|
||||
{!! Form::text("name",null,["class"=>"form-control".($errors->has('name')?" is-invalid":""),"autofocus",'placeholder'=>'Nombre del banco']) !!}
|
||||
<span id="error-name" class="invalid-feedback"></span>
|
||||
</div>
|
||||
</div>
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
<ul>
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
<div class="form-group row">
|
||||
<div class="col-md-3 col-lg-2"></div>
|
||||
<div class="col-md-4">
|
||||
<a href="{{url('banks')}}" class="btn btn-danger btn-xs">
|
||||
Atrás</a>
|
||||
{!! Form::button("Guardar",["type" => "submit","class"=>"btn btn-primary btn-xs"])!!}
|
||||
</div>
|
||||
</div>
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -1,72 +0,0 @@
|
||||
|
||||
@if (Auth::user()->role_id >= 5)
|
||||
<div class="container-fluid" style="height:100%">
|
||||
<div>
|
||||
@else
|
||||
<div class="container" style="margin:0 1em">
|
||||
@endif
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-7">
|
||||
<h3>Tarjetas</h3>
|
||||
</div>
|
||||
<div class="col-sm-5">
|
||||
<div class="pull-right">
|
||||
{!! Form::open(['method'=>'GET','url'=>'cards','class'=>'navbar-form navbar-left','role'=>'search']) !!}
|
||||
<div class="input-group">
|
||||
<input class="form-control" id="search"
|
||||
value="{{ request()->session()->get('search') }}"
|
||||
placeholder="Buscar" name="search"
|
||||
type="text" id="search"/>
|
||||
<div class="input-group-btn">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fa fa-search" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="vertical-align: middle"><a href="{{url('cards?field=id&sort='.(request()->session()->get('sort')=='asc'?'desc':'asc'))}}">ID</a></th>
|
||||
{{request()->session()->get('field')=='id'?(request()->session()->get('sort')=='asc'?'':''):''}}
|
||||
|
||||
<th style="vertical-align: middle"><a href="{{url('cards?field=user_id&sort='.(request()->session()->get('sort')=='asc'?'desc':'asc'))}}">Usuario</a></th>
|
||||
{{request()->session()->get('field')=='user_id'?(request()->session()->get('sort')=='asc'?'':''):''}}
|
||||
|
||||
<th style="vertical-align: middle"><a href="{{url('cards?field=user_id&sort='.(request()->session()->get('sort')=='asc'?'desc':'asc'))}}">Openpay ID</a></th>
|
||||
{{request()->session()->get('field')=='user_id'?(request()->session()->get('sort')=='asc'?'':''):''}}
|
||||
|
||||
<th style="vertical-align: middle"><a href="{{url('cards?field=token&sort='.(request()->session()->get('sort')=='asc'?'desc':'asc'))}}">Token</a></th>
|
||||
{{request()->session()->get('field')=='token'?(request()->session()->get('sort')=='asc'?'':''):''}}
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@php
|
||||
$i=1;
|
||||
@endphp
|
||||
@foreach ($cards as $card)
|
||||
<tr>
|
||||
<th>{{ $card->id }}</th>
|
||||
<th>{{ $card->user->name }}</th>
|
||||
<td>{{ $card->user->openpay_id }}</td>
|
||||
<td>{{ $card->token}}</td>
|
||||
<td>
|
||||
<input type="hidden" name="_method" value="delete"/>
|
||||
<a class="btn btn-danger btn-xs" title="Delete"
|
||||
href="javascript:if(confirm('¿Estás seguro de que quieres eliminar esta tarjeta?')) javascript:if(confirm('Usualmente no se deben eliminar tarjetas, ¿Estás seguro?')) ajaxDelete('{{url('cards/delete/'.$card->id)}}','{{csrf_token()}}')">
|
||||
<i class="fa fa-trash"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{{ $cards->links() }}
|
||||
</div>
|
||||
@@ -111,7 +111,7 @@
|
||||
@else
|
||||
<li class="nav-item dropdown">
|
||||
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre style="padding-left:55px;">
|
||||
<img src="{{ isset(Auth::user()->profile_photo) ? asset('img/users/' . Auth::user()->id . '/' . Auth::user()->profile_photo) : asset('img/users/default.png') }}" style="width:48px; height:auto; position:absolute; top:-5px; left:-1px; border-radius:50%"/>
|
||||
<img src="{{ Auth::user()->profile_photo ?? asset('img/users/default.png') }}" style="width:48px; height:auto; position:absolute; top:-5px; left:-1px; border-radius:50%"/>
|
||||
{{ Auth::user()->name }} <span class="caret"></span>
|
||||
</a>
|
||||
|
||||
|
||||
2
resources/views/cards/ajax.blade.php → resources/views/payment-batches/ajax.blade.php
Executable file → Normal file
2
resources/views/cards/ajax.blade.php → resources/views/payment-batches/ajax.blade.php
Executable file → Normal file
@@ -2,7 +2,7 @@
|
||||
|
||||
@section('content')
|
||||
<div id="content">
|
||||
@include('cards.index')
|
||||
@include('payment-batches.index')
|
||||
</div>
|
||||
<div class="loading">
|
||||
<i class="fa fa-refresh fa-spin fa-2x fa-tw"></i>
|
||||
56
resources/views/payment-batches/index.blade.php
Normal file
56
resources/views/payment-batches/index.blade.php
Normal file
@@ -0,0 +1,56 @@
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row mb-3">
|
||||
<div class="col">
|
||||
<h3>Pagos Realizados</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if(session('error'))
|
||||
<div class="alert alert-danger">{{ session('error') }}</div>
|
||||
@endif
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Archivo</th>
|
||||
<th>Generado por</th>
|
||||
<th>Fecha de generación</th>
|
||||
<th>Rango de fechas</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse($batches as $batch)
|
||||
<tr>
|
||||
<td>{{ $batch->id }}</td>
|
||||
<td>{{ $batch->file_name }}</td>
|
||||
<td>{{ optional($batch->user)->name ?? '—' }}</td>
|
||||
<td>{{ $batch->created_at->format('d/m/Y H:i') }}</td>
|
||||
<td>
|
||||
@if($batch->date_from || $batch->date_to)
|
||||
{{ $batch->date_from ? \Carbon\Carbon::parse($batch->date_from)->format('d/m/Y') : '—' }}
|
||||
al
|
||||
{{ $batch->date_to ? \Carbon\Carbon::parse($batch->date_to)->format('d/m/Y') : '—' }}
|
||||
@else
|
||||
Todos los registros
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ url('payment-batches/' . $batch->id . '/download') }}"
|
||||
class="btn btn-sm btn-outline-primary">
|
||||
<i class="fa fa-download"></i> Descargar
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="6" class="text-center text-muted">Sin pagos realizados aún.</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{{ $batches->links() }}
|
||||
</div>
|
||||
@@ -13,27 +13,53 @@
|
||||
$sortUrl = fn($f) => url('payments') . '?' . http_build_query(array_filter(['date_from' => $dateFrom, 'date_to' => $dateTo, 'field' => $f, 'sort' => $currentField === $f ? $nextSort : 'desc']));
|
||||
@endphp
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-5">
|
||||
<h3>Pagos a Proveedores</h3>
|
||||
@if(session('warning'))
|
||||
<div class="alert alert-warning">{{ session('warning') }}</div>
|
||||
@endif
|
||||
|
||||
<div class="row align-items-center mb-2">
|
||||
<div class="col-sm-4">
|
||||
<h3 class="mb-0">Pagos a Proveedores</h3>
|
||||
</div>
|
||||
<div class="col-sm-7">
|
||||
<div class="pull-right">
|
||||
{!! Form::open(['method' => 'GET', 'url' => 'payments', 'class' => 'form-inline', 'role' => 'search']) !!}
|
||||
<label class="mr-2 mb-0">Filtrar</label>
|
||||
<input type="date" class="form-control mr-1" name="date_from" value="{{ $dateFrom }}">
|
||||
<input type="date" class="form-control mr-1" name="date_to" value="{{ $dateTo }}">
|
||||
<button type="submit" class="btn btn-primary mr-1">
|
||||
<i class="fa fa-filter" aria-hidden="true"></i>
|
||||
<div class="col-sm-8">
|
||||
<div class="d-flex justify-content-end align-items-center flex-wrap" style="gap:.5rem">
|
||||
{!! Form::open(['method' => 'GET', 'url' => 'payments', 'class' => 'd-flex align-items-center', 'style' => 'gap:.4rem']) !!}
|
||||
<label class="mb-0 mr-1">Filtrar</label>
|
||||
<input type="date" class="form-control form-control-sm" name="date_from" value="{{ $dateFrom }}">
|
||||
<input type="date" class="form-control form-control-sm" name="date_to" value="{{ $dateTo }}">
|
||||
<button type="submit" class="btn btn-sm btn-primary">
|
||||
<i class="fa fa-filter"></i>
|
||||
</button>
|
||||
<a href="{{ url('payments') }}" class="btn btn-default">
|
||||
<i class="fa fa-times" aria-hidden="true"></i>
|
||||
<a href="{{ url('payments') }}" class="btn btn-sm btn-default">
|
||||
<i class="fa fa-times"></i>
|
||||
</a>
|
||||
{!! Form::close() !!}
|
||||
|
||||
<form method="POST" action="{{ url('payments/generate') }}" id="generateForm">
|
||||
@csrf
|
||||
<input type="hidden" name="date_from" value="{{ $dateFrom }}">
|
||||
<input type="hidden" name="date_to" value="{{ $dateTo }}">
|
||||
<button type="button" class="btn btn-sm btn-success" onclick="confirmGenerate()">
|
||||
<i class="fa fa-file-excel-o"></i> Generar Pagos
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function confirmGenerate() {
|
||||
var total = {{ $payments->total() }};
|
||||
if (total === 0) {
|
||||
alert('No hay contratos pendientes de pago.');
|
||||
return;
|
||||
}
|
||||
if (confirm('Se generará un archivo Excel con ' + total + ' proveedor(es) y se marcarán sus contratos como pagados. ¿Continuar?')) {
|
||||
document.getElementById('generateForm').submit();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
@@ -1,116 +1,279 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<script src="{{ asset('js/ajaxcrud.js') }}"></script>
|
||||
@if (Auth::user()->role_id >= 5)
|
||||
<div class="container-fluid" style="height:100%">
|
||||
<div>
|
||||
@else
|
||||
<div class="container" style="margin:0 1em">
|
||||
@endif
|
||||
@push('styles')
|
||||
<style>
|
||||
.chat-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
padding: 1rem;
|
||||
}
|
||||
.chat-info {
|
||||
background: #f8f9fa;
|
||||
border: 1px solid #dee2e6;
|
||||
border-radius: 8px;
|
||||
padding: 0.75rem 3.5rem 0.75rem 1rem;
|
||||
margin-bottom: 1rem;
|
||||
font-size: 0.85rem;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
position: relative;
|
||||
}
|
||||
.chat-info .btn-actions {
|
||||
position: absolute;
|
||||
right: 1rem;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
display: flex;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
.chat-info span { color: #495057; }
|
||||
.chat-info strong { color: #212529; }
|
||||
.chat-messages {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 0.5rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.bubble-row {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.bubble-row.right { justify-content: flex-end; }
|
||||
.bubble-row.left { justify-content: flex-start; }
|
||||
.bubble-row.center { justify-content: center; }
|
||||
.bubble {
|
||||
max-width: 60%;
|
||||
padding: 0.6rem 0.9rem;
|
||||
border-radius: 16px;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.4;
|
||||
position: relative;
|
||||
}
|
||||
.bubble-row.right .bubble {
|
||||
background: #0d6efd;
|
||||
color: #fff;
|
||||
border-bottom-right-radius: 4px;
|
||||
}
|
||||
.bubble-row.left .bubble {
|
||||
background: #198754;
|
||||
color: #fff;
|
||||
border-bottom-left-radius: 4px;
|
||||
}
|
||||
.bubble-row.center .bubble {
|
||||
background: #e9ecef;
|
||||
color: #495057;
|
||||
border-radius: 16px;
|
||||
font-style: italic;
|
||||
text-align: center;
|
||||
max-width: 70%;
|
||||
}
|
||||
.bubble-meta {
|
||||
font-size: 0.7rem;
|
||||
margin-top: 0.25rem;
|
||||
opacity: 0.75;
|
||||
}
|
||||
.bubble-row.right .bubble-meta { text-align: right; color: rgba(255,255,255,0.85); }
|
||||
.bubble-row.left .bubble-meta { text-align: left; color: rgba(255,255,255,0.85); }
|
||||
.bubble-row.center .bubble-meta { text-align: center; color: #6c757d; }
|
||||
.bubble-label {
|
||||
font-size: 0.7rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: 0.2rem;
|
||||
opacity: 0.85;
|
||||
}
|
||||
.chat-input {
|
||||
border-top: 1px solid #dee2e6;
|
||||
padding-top: 0.75rem;
|
||||
}
|
||||
.chat-input form {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
align-items: flex-start;
|
||||
}
|
||||
.chat-input textarea {
|
||||
flex: 1;
|
||||
resize: none;
|
||||
padding: 0.5rem 1rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
.chat-input button {
|
||||
border-radius: 20px;
|
||||
padding: 0.5rem 1.25rem;
|
||||
}
|
||||
.verdict-badge {
|
||||
background: #fff3cd;
|
||||
border: 1px solid #ffc107;
|
||||
border-radius: 8px;
|
||||
padding: 0.5rem 1rem;
|
||||
font-size: 0.85rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-7">
|
||||
<h3>Comentarios del reporte</h3>
|
||||
@section('content')
|
||||
@php
|
||||
$clientId = $contract->user_id;
|
||||
$supplierId = $contract->suppliers->user_id ?? null;
|
||||
@endphp
|
||||
|
||||
<div class="chat-wrapper">
|
||||
|
||||
{{-- Info del contrato --}}
|
||||
<div class="chat-info">
|
||||
<span><strong>Contrato #{{ $contract->id }}</strong></span>
|
||||
<span>Cliente: <strong>{{ $contract->user->name ?? '—' }}</strong></span>
|
||||
<span>Proveedor: <strong>{{ $contract->suppliers->company_name ?? '—' }}</strong></span>
|
||||
<span>Categoría: <strong>{{ $contract->categories->name ?? '—' }}</strong></span>
|
||||
<span>Monto: <strong>${{ $contract->amount }}</strong></span>
|
||||
<span>Cita: <strong>{{ $contract->appointment }}</strong></span>
|
||||
@if($report->veredict)
|
||||
<span>Veredicto: <strong>{{ $report->veredict }}</strong></span>
|
||||
@endif
|
||||
<div class="btn-actions">
|
||||
<button type="button" class="btn btn-info btn-xs" title="Ver detalles"
|
||||
data-toggle="modal" data-target="#modalDetalles">
|
||||
<i class="fa fa-info-circle"></i>
|
||||
</button>
|
||||
<a class="btn btn-secondary btn-xs" title="Veredicto"
|
||||
href="{{ url('reports/veredict/' . $report->id) }}">
|
||||
<i class="fa fa-gavel"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<h5>Contrato:</h5>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="vertical-align: middle">ID</th>
|
||||
{{-- Leyenda --}}
|
||||
<div class="d-flex gap-3 mb-2" style="font-size:0.78rem; gap:1rem;">
|
||||
<span><span style="display:inline-block;width:12px;height:12px;background:#0d6efd;border-radius:3px;"></span> Cliente</span>
|
||||
<span><span style="display:inline-block;width:12px;height:12px;background:#198754;border-radius:3px;"></span> Proveedor</span>
|
||||
<span><span style="display:inline-block;width:12px;height:12px;background:#e9ecef;border:1px solid #ccc;border-radius:3px;"></span> Moderador</span>
|
||||
</div>
|
||||
|
||||
<th style="vertical-align: middle">Usuario</th>
|
||||
{{-- Mensajes --}}
|
||||
<div class="chat-messages">
|
||||
@forelse($comments as $comment)
|
||||
@php
|
||||
if ($comment->user_id == $clientId) {
|
||||
$side = 'right';
|
||||
$label = 'Cliente';
|
||||
} elseif ($comment->user_id == $supplierId) {
|
||||
$side = 'left';
|
||||
$label = 'Proveedor';
|
||||
} else {
|
||||
$side = 'center';
|
||||
$label = 'Moderador';
|
||||
}
|
||||
@endphp
|
||||
|
||||
<th style="vertical-align: middle">Proveedor</th>
|
||||
<div class="bubble-row {{ $side }}">
|
||||
<div>
|
||||
<div class="bubble-label text-muted">{{ $label }} — {{ $comment->user->name ?? '—' }}</div>
|
||||
<div class="bubble">
|
||||
{{ $comment->comment }}
|
||||
<div class="bubble-meta">{{ $comment->created_at->format('d/m/Y H:i') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@empty
|
||||
<p class="text-center text-muted mt-4">Sin comentarios aún.</p>
|
||||
@endforelse
|
||||
</div>
|
||||
|
||||
<th style="vertical-align: middle">Categoría</th>
|
||||
{{-- Paginación --}}
|
||||
@if($comments->hasPages())
|
||||
<div class="mb-2">{{ $comments->links() }}</div>
|
||||
@endif
|
||||
|
||||
<th style="vertical-align: middle">Dirección</th>
|
||||
{{-- Input del moderador --}}
|
||||
<div class="chat-input">
|
||||
<form method="POST" action="{{ url('reports/' . $report->id . '/comments') }}">
|
||||
@csrf
|
||||
@error('comment')
|
||||
<div class="text-danger mb-1" style="font-size:0.8rem;">{{ $message }}</div>
|
||||
@enderror
|
||||
<textarea name="comment" rows="2" class="form-control" placeholder="Escribir comentario como moderador..."></textarea>
|
||||
<button type="submit" class="btn btn-primary mt-2">Enviar</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<th style="vertical-align: middle">Cita</th>
|
||||
</div>
|
||||
|
||||
<th style="vertical-align: middle">Monto</th>
|
||||
{{-- Modal fuera del chat-wrapper para evitar stacking context del flex --}}
|
||||
<div class="modal fade" id="modalDetalles" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Detalles del Contrato #{{ $contract->id }}</h5>
|
||||
<button type="button" class="close" data-dismiss="modal">
|
||||
<span>×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<th style="vertical-align: middle">Calificación</th>
|
||||
<h6 class="font-weight-bold mb-2">Información del contrato</h6>
|
||||
<table class="table table-sm table-borderless mb-4">
|
||||
<tr><th style="width:35%">Cliente</th><td>{{ $contract->user->name ?? '—' }}</td></tr>
|
||||
<tr><th>Proveedor</th><td>{{ $contract->suppliers->company_name ?? '—' }}</td></tr>
|
||||
<tr><th>Categoría</th><td>{{ $contract->categories->name ?? '—' }}</td></tr>
|
||||
<tr><th>Dirección</th><td>{{ $contract->address }}</td></tr>
|
||||
<tr><th>Cita</th><td>{{ $contract->appointment }}</td></tr>
|
||||
<tr><th>Monto</th><td>${{ $contract->amount }}</td></tr>
|
||||
<tr><th>Estado</th><td>{{ $contract->status->name ?? $contract->status_id }}</td></tr>
|
||||
<tr><th>Transaction ID</th><td><code>{{ $contract->transaction_id ?? '—' }}</code></td></tr>
|
||||
</table>
|
||||
|
||||
<th style="vertical-align: middle">Comentarios</th>
|
||||
@if($nohome)
|
||||
<hr>
|
||||
<h6 class="font-weight-bold mb-2">Evidencia del proveedor (No Home)</h6>
|
||||
<table class="table table-sm table-borderless mb-3">
|
||||
<tr>
|
||||
<th style="width:35%">Descripción</th>
|
||||
<td>{{ $nohome->house_description ?? '—' }}</td>
|
||||
</tr>
|
||||
@if($nohome->location)
|
||||
<tr>
|
||||
<th>Coordenadas GPS</th>
|
||||
<td>
|
||||
{{ $nohome->location->getLatitude() }}, {{ $nohome->location->getLongitude() }}
|
||||
<a href="https://www.google.com/maps?q={{ $nohome->location->getLatitude() }},{{ $nohome->location->getLongitude() }}"
|
||||
target="_blank" class="btn btn-xs btn-outline-secondary ml-2">
|
||||
<i class="fa fa-map-marker"></i> Ver en mapa
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endif
|
||||
</table>
|
||||
@if($nohome->house_photo)
|
||||
<img src="{{ $nohome->house_photo }}" alt="Foto del domicilio"
|
||||
class="img-fluid rounded" style="max-height:400px;">
|
||||
@endif
|
||||
@else
|
||||
<hr>
|
||||
<p class="text-muted mb-0"><em>El proveedor no registró evidencia de visita.</em></p>
|
||||
@endif
|
||||
|
||||
<th style="vertical-align: middle">Transacción ID</th>
|
||||
|
||||
<th style="vertical-align: middle">Fecha de creación</th>
|
||||
|
||||
<th style="vertical-align: middle">Fecha de fuera de casa</th>
|
||||
|
||||
<th style="vertical-align: middle">Confirmación de descripción de la casa</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@php
|
||||
$i=1;
|
||||
@endphp
|
||||
<tr>
|
||||
<th>{{ $contract->id }}</th>
|
||||
<td>{{ $contract->user->name ?? null }}</td>
|
||||
<td>{{ $contract->suppliers->company_name ?? null }}</td>
|
||||
<td>{{ $contract->categories->name ?? null }}</td>
|
||||
<td>{{ $contract->address }}</td>
|
||||
<td>{{ $contract->appointment }}</td>
|
||||
<td>${{ $contract->amount }}</td>
|
||||
<td>{{ $contract->score }}</td>
|
||||
<td>{{ $contract->comments }}</td>
|
||||
<td>{{ $contract->transaction_id }}</td>
|
||||
<td>{{ $contract->created_at }}</td>
|
||||
<td>{{ isset($nohome->confirmed_at) }}</td>
|
||||
<td>{{ isset($nohome->house_description) }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br><br>
|
||||
<h5>Comentarios:</h5>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="vertical-align: middle"><a href="{{url('comments?field=user_id&sort='.(request()->session()->get('sort')=='asc'?'desc':'asc'))}}">Usuario</a></th>
|
||||
{{request()->session()->get('field')=='user_id'?(request()->session()->get('sort')=='asc'?'':''):''}}
|
||||
|
||||
<th style="vertical-align: middle"><a href="{{url('comments?field=user_id&sort='.(request()->session()->get('sort')=='asc'?'desc':'asc'))}}">Teléfono</a></th>
|
||||
{{request()->session()->get('field')=='user_id'?(request()->session()->get('sort')=='asc'?'':''):''}}
|
||||
|
||||
<th style="vertical-align: middle"><a href="{{url('comments?field=comment&sort='.(request()->session()->get('sort')=='asc'?'desc':'asc'))}}">Comentario</a></th>
|
||||
{{request()->session()->get('field')=='comment'?(request()->session()->get('sort')=='asc'?'':''):''}}
|
||||
|
||||
<th style="vertical-align: middle"><a href="{{url('contracts?field=created_at&sort='.(request()->session()->get('sort')=='asc'?'desc':'asc'))}}">Fecha de creación</a></th>
|
||||
{{request()->session()->get('field')=='created_at'?(request()->session()->get('sort')=='asc'?'':''):''}}
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@php
|
||||
$i=1;
|
||||
@endphp
|
||||
@foreach ($comments as $comment)
|
||||
<tr>
|
||||
<td>{{ $comment->user->name }}</td>
|
||||
<td>{{ $comment->user->phone }}</td>
|
||||
<td>{{ $comment->comment }}</td>
|
||||
<td>{{ $comment->created_at }}</td>
|
||||
<td style="width: 3em">
|
||||
<input type="hidden" name="_method" value="delete"/>
|
||||
<a class="btn btn-danger btn-xs" title="Delete"
|
||||
href="javascript:if(confirm('¿Estás seguro de que quieres eliminar este comentario?')) javascript:if(confirm('Usualmente no se deben eliminar comentarios, solo editarlos ¿Estás seguro?')) ajaxDeleteComments('{{url('reports/comments/delete/'.$comment->id.'/'.$contract->id)}}','{{csrf_token()}}')">
|
||||
<i class="fa fa-trash"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{{ $comments->links() }}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cerrar</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('js')
|
||||
<script>
|
||||
// main-content tiene overflow-y:auto que crea stacking context
|
||||
// Mover el modal a body para que Bootstrap pueda posicionarlo correctamente
|
||||
$(document).ready(function () {
|
||||
$('#modalDetalles').appendTo('body');
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
@@ -57,13 +57,9 @@
|
||||
<td>{{ $report->veredict }}</td>
|
||||
<td style="width: 10em">
|
||||
<a class="btn btn-primary btn-xs" title="Comments"
|
||||
href="{{url('reports/comments/'.$report->id.'/'.$report->contract_id)}}">
|
||||
href="{{url('reports/'.$report->id.'/comments')}}">
|
||||
<i class="fa fa-comments"></i>
|
||||
</a>
|
||||
<a class="btn btn-secondary btn-xs" title="Veredict"
|
||||
href="{{url('reports/veredict/'.$report->id)}}">
|
||||
<i class="fa fa-gavel"></i>
|
||||
</a>
|
||||
<input type="hidden" name="_method" value="delete"/>
|
||||
<a class="btn btn-danger btn-xs" title="Delete"
|
||||
href="javascript:if(confirm('¿Estás seguro de que quieres eliminar este reporte?')) javascript:if(confirm('Usualmente no se deben eliminar reportes, solo editarlos ¿Estás seguro?')) ajaxDelete('{{url('reports/delete/'.$report->id)}}','{{csrf_token()}}')">
|
||||
|
||||
@@ -17,6 +17,20 @@
|
||||
<span id="error-name" class="invalid-feedback"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
{!! Form::label("contract_status","Acción sobre el contrato",["class"=>"col-form-label col-md-3 col-lg-2"]) !!}
|
||||
<div class="col-md-8">
|
||||
{!! Form::select("contract_status", [
|
||||
'' => '— Sin cambio de estatus —',
|
||||
'8' => 'Devuelto al cliente (reembolso Stripe)',
|
||||
'9' => 'Disputa terminada (pagar al proveedor)',
|
||||
], null, ["class"=>"form-control"]) !!}
|
||||
<small class="text-muted">
|
||||
"Devuelto al cliente" emite el reembolso en Stripe automáticamente.
|
||||
"Disputa terminada" aparece en la sección de Pagos.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
<ul>
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
<a href="/banks" class="sidebar-link {{ Request::is('banks*') ? 'active' : '' }}">
|
||||
<i class="fa fa-university"></i> Bancos
|
||||
</a>
|
||||
<a href="/cards" class="sidebar-link {{ Request::is('cards*') ? 'active' : '' }}">
|
||||
<i class="fa fa-credit-card"></i> Tarjetas
|
||||
</a>
|
||||
<a href="/payments" class="sidebar-link {{ Request::is('payments*') ? 'active' : '' }}">
|
||||
<a href="/payments" class="sidebar-link {{ Request::is('payments') ? 'active' : '' }}">
|
||||
<i class="fa fa-money"></i> Pagos
|
||||
</a>
|
||||
<a href="/payment-batches" class="sidebar-link {{ Request::is('payment-batches*') ? 'active' : '' }}">
|
||||
<i class="fa fa-history"></i> Pagos Realizados
|
||||
</a>
|
||||
<a href="/postulations" class="sidebar-link {{ Request::is('postulations*') ? 'active' : '' }}">
|
||||
<i class="fa fa-file-text"></i> Postulaciones
|
||||
</a>
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
'4' => 'Facturación',
|
||||
'5' => 'Moderador',
|
||||
'6' => 'Administrador',
|
||||
'7' => 'SuperAdmin'
|
||||
'7' => 'SuperAdmin',
|
||||
'8' => 'Técnico'
|
||||
), $user->roles->id) !!}
|
||||
<span id="error-name" class="invalid-feedback"></span>
|
||||
</div>
|
||||
@@ -42,13 +43,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row required">
|
||||
{!! Form::label("openpay_id","Openpay ID",["class"=>"col-form-label col-md-3 col-lg-2"]) !!}
|
||||
<div class="col-md-8">
|
||||
{!! Form::text("openpay_id",null,["class"=>"form-control".($errors->has('openpay_id')?" is-invalid":""),'placeholder'=>'Openpay ID']) !!}
|
||||
<span id="error-openpay_id" class="invalid-feedback"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
<ul>
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
<th style="vertical-align: middle"><a href="{{url('users?field=id&sort='.(request()->session()->get('sort')=='asc'?'desc':'asc'))}}">ID</a></th>
|
||||
{{request()->session()->get('field')=='id'?(request()->session()->get('sort')=='asc'?'':''):''}}
|
||||
|
||||
<th style="vertical-align: middle">Foto</th>
|
||||
|
||||
<th style="vertical-align: middle"><a href="{{url('users?field=name&sort='.(request()->session()->get('sort')=='asc'?'desc':'asc'))}}">Nombre</a></th>
|
||||
{{request()->session()->get('field')=='name'?(request()->session()->get('sort')=='asc'?'':''):''}}
|
||||
|
||||
@@ -70,6 +72,13 @@
|
||||
@foreach ($users as $user)
|
||||
<tr>
|
||||
<th>{{ $user->id }}</th>
|
||||
<td>
|
||||
@if($user->profile_photo)
|
||||
<img src="{{ $user->profile_photo }}" style="width:36px;height:36px;object-fit:cover;border-radius:50%;">
|
||||
@else
|
||||
<span class="text-muted">—</span>
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ $user->name }}</td>
|
||||
<td >{{ $user->email }}</td>
|
||||
<td >{{ $user->roles->name }}</td>
|
||||
|
||||
@@ -37,9 +37,7 @@ Route::group([
|
||||
'prefix' => 'payments',
|
||||
'middleware' => 'auth:api'
|
||||
], function() {
|
||||
Route::post('addcard', 'PaymentController@addcard');
|
||||
Route::post('deletecard', 'PaymentController@deletecard');
|
||||
Route::get('getcards', 'PaymentController@getcards');
|
||||
Route::post('intent', 'PaymentController@intent');
|
||||
});
|
||||
|
||||
Route::group([
|
||||
@@ -57,6 +55,9 @@ Route::group([
|
||||
Route::post('review', 'ContractController@reviewcontract');
|
||||
Route::post('extra', 'ContractController@extra');
|
||||
Route::post('report', 'ReportController@report');
|
||||
Route::get('reports', 'ReportController@getreports');
|
||||
Route::get('reports/{id}/comments', 'ReportController@getcomments');
|
||||
Route::post('reports/{id}/comments', 'ReportController@storecomment');
|
||||
Route::get('nohome-check', 'NoHomeController@nohomecheck');
|
||||
Route::post('nohome-confirm', 'NoHomeController@nohomeconfirm');
|
||||
//Route::post('nohome-test', 'NoHomeController@test');
|
||||
@@ -74,8 +75,16 @@ Route::group([
|
||||
Route::get('get-postulations', 'SupplierController@getpostulation');
|
||||
Route::get('get-contracted-postulations', 'SupplierController@getcontractedpostulation');
|
||||
Route::get('get-finished-postulations', 'PostulationController@getfinishedpostulations');
|
||||
Route::get('postulations/reports', 'ReportController@getsupplierreports');
|
||||
Route::get('get-postulants', 'PostulationController@getpostulants');
|
||||
Route::post('postulate', 'PostulationController@postulate');
|
||||
|
||||
// Técnicos
|
||||
Route::get('technicians', 'TechnicianController@index');
|
||||
Route::get('technicians/find', 'TechnicianController@find');
|
||||
Route::post('technicians/add', 'TechnicianController@store');
|
||||
Route::delete('technicians/{id}', 'TechnicianController@destroy');
|
||||
Route::post('contracts/assign-technician', 'TechnicianController@assign');
|
||||
});
|
||||
|
||||
Route::get('/parameters', 'IChambaParameterController@parameters');
|
||||
|
||||
@@ -56,14 +56,6 @@ Route::group([
|
||||
Route::match(['get', 'put'], 'update/{id}', 'BanksController@update')->middleware('rolecheck:6');
|
||||
Route::match(['get', 'post'], 'create', 'BanksController@create')->middleware('rolecheck:6');
|
||||
});
|
||||
Route::group([
|
||||
'prefix' => 'cards'
|
||||
], function() {
|
||||
Route::get('/', 'PaymentController@cardsindex')->middleware('rolecheck:6');
|
||||
Route::delete('delete/{id}', 'PaymentController@destroy')->middleware('superadmin');
|
||||
//Route::match(['get', 'put'], 'update/{id}', 'PaymentController@update')->middleware('rolecheck:6');
|
||||
//Route::match(['get', 'post'], 'create', 'PaymentController@create')->middleware('rolecheck:6');
|
||||
});
|
||||
Route::group([
|
||||
'prefix' => 'coupons'
|
||||
], function() {
|
||||
@@ -92,10 +84,17 @@ Route::group([
|
||||
'prefix' => 'payments'
|
||||
], function() {
|
||||
Route::get('/', 'PaymentController@index')->middleware('rolecheck:6');
|
||||
Route::post('generate', 'PaymentController@generate')->middleware('rolecheck:6');
|
||||
Route::delete('delete/{id}', 'StatusController@destroy')->middleware('superadmin');
|
||||
Route::match(['get', 'put'], 'update/{id}', 'StatusController@update')->middleware('rolecheck:6');
|
||||
Route::match(['get', 'post'], 'create', 'StatusController@create')->middleware('rolecheck:6');
|
||||
});
|
||||
Route::group([
|
||||
'prefix' => 'payment-batches'
|
||||
], function() {
|
||||
Route::get('/', 'PaymentBatchController@index')->middleware('rolecheck:6');
|
||||
Route::get('{id}/download', 'PaymentBatchController@download')->middleware('rolecheck:6');
|
||||
});
|
||||
Route::group([
|
||||
'prefix' => 'postulations'
|
||||
], function() {
|
||||
@@ -126,9 +125,10 @@ Route::group([
|
||||
], function() {
|
||||
Route::get('/', 'ReportController@index')->middleware('rolecheck:6');
|
||||
Route::delete('delete/{id}', 'ReportController@destroy')->middleware('superadmin');
|
||||
Route::get('comments/{id}/{contract_id}', 'ReportCommentController@index')->middleware('rolecheck:6');
|
||||
Route::delete('comments/delete/{id}/{contract_id}', 'ReportCommentController@destroy')->middleware('superadmin');
|
||||
Route::get('veredict/{id}', 'ReportController@veredict')->middleware('rolecheck:6');
|
||||
Route::get('{id}/comments', 'ReportCommentController@index')->middleware('rolecheck:6');
|
||||
Route::post('{id}/comments', 'ReportCommentController@store')->middleware('rolecheck:6');
|
||||
Route::delete('{id}/comments/{comment_id}', 'ReportCommentController@destroy')->middleware('superadmin');
|
||||
Route::match(['get', 'post'], 'veredict/{id}', 'ReportController@veredict')->middleware('rolecheck:6');
|
||||
//Route::match(['get', 'post'], 'create', 'CouponController@create')->middleware('rolecheck:6');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user