<?php use App\User; use App\Worker; use App\Branch; use App\UserLevel; use App\Notification; use App\Provider; use App\ProviderBill; use App\ProviderBillBreakdown; use App\Stock; $currentNotification = Notification::find($notification); $currentNotification->Seen = true; $currentNotification->save(); $permissions = json_decode(UserLevel::find(Auth::user()->UserLevel)->Permissions); $provider = Provider::find($pId); $bill = ProviderBill::where('ProviderId', '=', $pId)->where('BillNumber', '=', $bill)->first(); $billBreakdown = ProviderBillBreakdown::where('ProviderBillId', '=', $bill->Id)->get(); $worker = Worker::find(Auth::user()->TypeId); $total = 0; ?> <!DOCTYPE html> <html lang="es"> <head> <title>Eirene Systema Administrativo</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta charset="UTF-8"> <meta name="csrf-token" content="{{{ Session::token() }}}"> <link href="{{ URL::to('/') }}/css/bootstrap.min.css" rel="stylesheet"> <link href="{{ URL::to('/') }}/css/bootstrap-responsive.min.css" rel="stylesheet">
/** * Function that generates order. * * @return Response */ public function updateAI() { // Validate Input. $validator = Validator::make(Input::all(), array('provider' => 'required', 'orderRange' => 'required', 'sampleRange' => 'required', 'aiActivate' => 'required')); if ($validator->fails()) { return response()->json(['error' => 'Informacion incompleta!']); } // Check that user is part of authorized staff. if (Auth::user()->Type != 1) { // If they are unauthorized no point in returning anything. return response()->json(array()); } // Get provider. $provider = Provider::find(Input::get('provider')); // Update and save it. $provider->OrderRange = Input::get('orderRange'); $provider->SampleRange = Input::get('sampleRange'); $provider->AIManaged = Input::get('aiActivate') == 'on' ? true : false; $provider->save(); $response['state'] = 'Success'; return response()->json($response); }
public function getProvider() { // Validate Input. $validator = Validator::make(Input::all(), array('provider' => 'required')); if ($validator->fails()) { return response()->json(['error' => 'Informacion incompleta!']); } // Check that user is part of authorized staff. if (Auth::user()->Type != 1) { // If they are unauthorized no point in returning anything. return response()->json(['state' => 'Unauthorized']); } // Get the provider. $provider = Provider::find(Input::get('provider')); // Return provider info. $response['state'] = 'Success'; $response['provider'] = $provider; return response()->json($response); }
<?php use App\AIOrder; use App\AIOrderBreakdown; use App\Provider; use App\Branch; use App\Stock; // Get the provider and branch. $provider = Provider::find($order['ProviderId']); $branch = Branch::find($order['BranchId']); function getName($code, $branchId) { // Get product. $product = Stock::where('Code', '=', $code)->where('BranchId', '=', $branchId)->first(); return $product->Description; } ?> <p>{{ $provider->Name }},</p> <p>Les enviamos el siguiente correo para realizar una orden a su empresa para los siguientes productos:</p> <table width="600" align="center" style="border:1px solid black;"> <thead> <tr><th>Descripcion</th><th>Cantidad</th></tr> </thead> <tbody> @foreach($breakdown as $product) <tr><td style="text-align:center;">{{ getName($product['Code'], $branch->Id) }}</td><td style="text-align:center;">{{ $product['Quantity'] }}</td></tr> @endforeach </tbody> </table> <p>Por favor enviar los productos a {{ $branch->Name }} ubicados en {{ $branch->Address }}. Recuerde responder a este correo con la palabra: Recibido. Esto es para permitirnos saber de que han recibido la orden exitosamente.</p> <p>Se despide cordialmente,</p>
/** * Function that pays amount to specified bill. * * @return Response */ public function payExisting() { // Validate Input. $validator = Validator::make(Input::all(), array('formData' => 'required')); $response = array(); if ($validator->fails()) { $response['state'] = 'Error'; $response['error'] = 'Informacion incompleta!'; return response()->json($response); } // Check that user is part of authorized staff. if (Auth::user()->Type != 1) { // If they are unauthorized no point in returning anything. return response()->json(array()); } // Get the bill. $bill = ProviderBill::where('ProviderId', '=', Input::get('formData')['peBillProvider'])->where('BillNumber', '=', Input::get('formData')['peBillNumber'])->first(); if (!$bill) { $response['state'] = 'Error'; $response['error'] = 'Factura inexistente!'; return response()->json($response); } if ($bill->State == 2) { $response['state'] = 'Error'; $response['error'] = 'Esta factura ya ha sido cancelada!'; return response()->json($response); } // Get the payments. $payments = ProviderBillPayment::where('ProviderBillId', '=', $bill->Id)->get(); $due = 0; foreach ($payments as $payment) { $due = $payment->Debt; } $amount = Input::get('formData')['peBillAmount']; if ($amount > $due) { $response['state'] = 'Error'; $response['error'] = 'No se puede hacer un pago mayor a lo que se debe!'; return response()->json($response); } // Get cashbox. $userId = Auth::user()->Id; $cashbox = Cashbox::where('UserId', '=', $userId)->where('Close', '=', NULL)->first(); if (!$cashbox) { $response['state'] = 'Error'; $response['error'] = 'No se encontro una caja abierta!'; return response()->json($response); } $provider = Provider::find(Input::get('formData')['peBillProvider']); $reason = "Pago a {$provider->Name} por Factura Numero: " . Input::get('formData')['peBillNumber']; $transaction = CashboxTransaction::create(array('CashboxId' => $cashbox->Id, 'DateTime' => date('Y-m-d H:i:s'), 'Type' => 2, 'Amount' => $amount, 'Reason' => $reason)); $due -= $amount; $billPayment = ProviderBillPayment::create(array('ProviderBillId' => $bill->Id, 'TransactionId' => $transaction->Id, 'Date' => date('Y-m-d'), 'Payment' => $amount, 'Debt' => $due)); if ($due == 0) { $bill->State = 2; $bill->save(); } $response['state'] = 'Success'; $response['message'] = 'Pago agregado exitosamente!'; // Return result. return response()->json($response); }
public function updateProvider() { // Validate Input. $validator = Validator::make(Input::all(), array('formData' => 'required', 'provider' => 'required')); if ($validator->fails()) { return response()->json(['error' => 'Informacion incompleta!']); } // Check that user is part of authorized staff. if (Auth::user()->Type != 1) { // If they are unauthorized no point in returning anything. return response()->json(['state' => 'Unauthorized']); } // Get provider. $provider = Provider::find(Input::get('provider')); // Make changes. $provider->Name = Input::get('formData')['ppcName']; $provider->Phone = Input::get('formData')['ppcPhone']; $provider->Email = Input::get('formData')['ppcEmail']; $provider->RUC = Input::get('formData')['ppcRUC']; $provider->Web = Input::get('formData')['ppcWeb']; $provider->Retainer = Input::get('formData')['ppcRetainer'] == 'true' ? true : false; $provider->CreditLimit = Input::get('formData')['ppcLimit']; $provider->CreditDays = Input::get('formData')['ppcDays']; // Save changes. $provider->save(); // Return provider info. $response['state'] = 'Success'; $response['message'] = 'Proveedor actualizado exitosamente!'; $response['provider'] = $provider; return response()->json($response); }
use App\UserLevel; use App\Notification; use App\AIOrder; use App\AIOrderBreakdown; use App\Stock; use App\Service; use App\Provider; $currentNotification = Notification::find($notification); $currentNotification->Seen = true; $currentNotification->save(); $permissions = json_decode(UserLevel::find(Auth::user()->UserLevel)->Permissions); $order = AIOrder::find($id); $orderBreakdown = AIOrderBreakdown::where('AIOrderId', '=', $order->Id)->get(); $worker = Worker::find(Auth::user()->TypeId); $branch = Branch::find($worker->BranchId); $provider = Provider::find($order->ProviderId); ?> <!DOCTYPE html> <html lang="es"> <head> <title>Eirene Systema Administrativo</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta charset="UTF-8"> <meta name="csrf-token" content="{{{ Session::token() }}}"> <link href="{{ URL::to('/') }}/css/bootstrap.min.css" rel="stylesheet"> <link href="{{ URL::to('/') }}/css/bootstrap-responsive.min.css" rel="stylesheet"> <link href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600" rel="stylesheet"> <link href="{{ URL::to('/') }}/css/font-awesome.css" rel="stylesheet"> <link href="{{ URL::to('/') }}/css/style.css" rel="stylesheet">
function getProvider($id) { return Provider::find($id); }
<?php use App\User; use App\Worker; use App\Branch; use App\UserLevel; use App\Notification; use App\Stock; use App\Provider; $currentNotification = Notification::find($notification); $currentNotification->Seen = true; $currentNotification->save(); $permissions = json_decode(UserLevel::find(Auth::user()->UserLevel)->Permissions); $worker = Worker::find(Auth::user()->TypeId); $product = Stock::where('Code', '=', $code)->where('BranchId', '=', $id)->first(); $provider = Provider::find($product->ProviderId); ?> <!DOCTYPE html> <html lang="es"> <head> <title>Eirene Systema Administrativo</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta charset="UTF-8"> <meta name="csrf-token" content="{{{ Session::token() }}}"> <link href="{{ URL::to('/') }}/css/bootstrap.min.css" rel="stylesheet"> <link href="{{ URL::to('/') }}/css/bootstrap-responsive.min.css" rel="stylesheet"> <link href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600" rel="stylesheet"> <link href="{{ URL::to('/') }}/css/font-awesome.css" rel="stylesheet"> <link href="{{ URL::to('/') }}/css/style.css" rel="stylesheet">
/** * Function that gets transaction Data. * * @return Response */ public function transactionData() { // Validate Input. $validator = Validator::make(Input::all(), array('id' => 'required')); $response = array(); if ($validator->fails()) { $response['state'] = 'Error'; $response['error'] = 'La identification de la transaccion es necesaria!'; return response()->json($response); } // Check that user is part of authorized staff. if (Auth::user()->Type != 1) { $response['state'] = 'No Autorizado'; $response['error'] = 'Usuario no autorizado!'; return response()->json($response); } // Get transaction Data. $transaction = CashboxTransaction::find(Input::get('id')); if (!$transaction) { $response['state'] = 'Fail'; $response['error'] = 'Esta transaccion no existe!'; return response()->json($response); } // Modify transaction Data. $transaction->DateTime = date('Y-m-d', strtotime($transaction->DateTime)); // Get cashbox. $cashbox = Cashbox::find($transaction->CashboxId); // Get worker. $worker = Worker::find(User::find($cashbox->UserId)->TypeId); if ($transaction->Type == 1 || $transaction->Type == 7) { // Get sale. $sale = Sale::where('TransactionId', '=', $transaction->Id)->first(); // Get items in sale. $items = SaleBreakdown::where('SaleId', '=', $sale->Id)->get(); $itemsData = array(); // Loop trough sales breakdown and extract products or services data. foreach ($items as $item) { $product = Stock::where('Code', '=', $item->Code)->where('BranchId', '=', $sale->BranchId)->first(); if (!$product) { $service = Service::where('Code', '=', $item->Code)->where('BranchId', '=', $sale->BranchId)->first(); array_push($itemsData, $service); } else { array_push($itemsData, $product); } } // Now get client or institution information. $creditor = array('Name' => 'No Asignado.', 'Address' => 'No Asignado.', 'Id' => 'No Asignado'); if ($sale->CreditorId != 0) { if ($sale->CreditorType == 1) { $creditor = Client::find($sale->CreditorId); } else { $creditor = Institution::find($sale->CreditorId); } } // Now return transaction data. $response['state'] = 'Success'; $response['transaction'] = $transaction; $response['cashbox'] = $cashbox; $response['worker'] = $worker; $response['sale'] = $sale; $response['items'] = $items; $response['itemsData'] = $itemsData; $response['creditor'] = $creditor; return response()->json($response); } else { // Check if this is a payment for a provider bill. if ($transaction->Type == 2) { // Get the provider bill information. $providerBillPayment = ProviderBillPayment::where('TransactionId', '=', $transaction->Id)->first(); // Get the provider bill and provider. $providerBill = ProviderBill::find($providerBillPayment->ProviderBillId); $provider = Provider::find($providerBill->ProviderId); // Get all debt from provider. $providerBills = ProviderBill::where('State', '=', 1)->where('ProviderId', '=', $provider->Id)->get(); $totalDebt = 0; foreach ($providerBills as $bill) { $totalDebt += $bill->Value; } // Get all payments. $providerBillPayments = ProviderBillPayment::where('ProviderBillId', '=', $providerBill->Id)->get(); // Get name of worker that made each payment. foreach ($providerBillPayments as $payment) { $tempTransaction = CashboxTransaction::find($payment->TransactionId); $workerName = Worker::find(User::find(Cashbox::find($tempTransaction->CashboxId)->UserId)->TypeId)->Name; $payment['Name'] = $workerName; } // Return what we have. $response['state'] = 'Success'; $response['transaction'] = $transaction; $response['cashbox'] = $cashbox; $response['worker'] = $worker; $response['date'] = date('Y-m-d'); $response['totalDebt'] = $totalDebt; $response['provider'] = $provider; $response['providerBill'] = $providerBill; $response['providerBillPayments'] = $providerBillPayments; } else { // No special information needed, just return what we have. $response['state'] = 'Success'; $response['transaction'] = $transaction; $response['cashbox'] = $cashbox; $response['worker'] = $worker; } return response()->json($response); } }