/**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     $configuration = Configuration::findOrFail($id);
     $this->validate($request, Configuration::$rules);
     $configuration->update($request->all());
     return redirect('configurations')->with('success', l('This record has been successfully updated &#58&#58 (:id) ', ['id' => $id], 'layouts') . $request->get('name'));
 }
Exemplo n.º 2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $configuration = Configuration::find($id);
     $configuration->update($request->all());
     $configuration->save();
     return redirect('admin/configurations');
 }
Exemplo n.º 3
0
 public static function percent($percent = 0, $decimalPlaces = null)
 {
     if ($decimalPlaces == null) {
         $decimalPlaces = Configuration::get('DEF_PERCENT_DECIMALS');
     }
     $number = number_format($percent, $decimalPlaces, '.', '');
     return $number;
 }
Exemplo n.º 4
0
 public function run()
 {
     // Uncomment the below to wipe the table clean before populating
     DB::table('addresses')->delete();
     $aconfigurations = array(array('id' => '1', 'alias' => 'Main Address', 'model_name' => 'Company', 'name_commercial' => 'Wath, Ltd.', 'address1' => '123th Fake St.', 'address2' => 'duplicado', 'postcode' => '28001', 'city' => 'Alcafrán', 'state' => 'Madrid', 'country' => 'España', 'firstname' => '', 'lastname' => '', 'email' => '*****@*****.**', 'phone' => '911234567', 'phone_mobile' => '618121200', 'fax' => '', 'notes' => '', 'active' => '1', 'owner_id' => '1', 'created_at' => \Carbon\Carbon::createFromDate(2015, 03, 31)->toDateTimeString(), 'updated_at' => \Carbon\Carbon::now()->toDateTimeString()));
     // Uncomment the below to run the seeder
     DB::table('addresses')->insert($aconfigurations);
     // Uncomment the below to wipe the table clean before populating
     DB::table('companies')->delete();
     $configurations = array(array('id' => '1', 'name_fiscal' => 'Work at Home, Ltd.', 'name_commercial' => 'Wath, Ltd.', 'identification' => '12345678E', 'website' => '', 'notes' => '', 'address_id' => '1', 'currency_id' => '1', 'created_at' => \Carbon\Carbon::createFromDate(2015, 03, 31)->toDateTimeString(), 'updated_at' => \Carbon\Carbon::now()->toDateTimeString()));
     // Uncomment the below to run the seeder
     DB::table('companies')->insert($configurations);
     Configuration::updateValue('DEF_COMPANY', 1);
 }
Exemplo n.º 5
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // Get all reservations that are still valid.
     $reservations = Reservation::where('State', '=', 'fresh')->get();
     // Get the configuration information.
     $config = Configuration::find(0);
     foreach ($reservations as $reservation) {
         // Check if they should become expired.
         if (date('Y-m-d', strtotime($reservation->Created) + 86400 * $config->ReservationLife) < date('Y-m-d')) {
             $reservation->State = 'late';
             $reservation->save();
         }
     }
 }
Exemplo n.º 6
0
 public static function date_short(\Carbon\Carbon $date, $format = '')
 {
     // http://laravel.io/forum/03-11-2014-date-format
     // https://laracasts.com/forum/?p=764-saving-carbon-dates-from-user-input/0
     if ($format == '') {
         $format = \App\Configuration::get('DATE_FORMAT_SHORT');
     }
     // Should take value after User / Environment settings
     // echo ($format); die();
     // $date = \Carbon\Carbon::createFromFormat($format, $date);
     // http://laravel.io/forum/03-12-2014-class-carbon-not-found?page=1
     // echo $date.' - '.Configuration::get('DATE_FORMAT_SHORT').' - '.$date->format($format); die();
     return $date->format($format);
 }
Exemplo n.º 7
0
 public function index()
 {
     $parsedown = new \ParsedownExtra();
     $config = Configuration::find(1);
     $posts = Post::published()->orderBy('published_at', 'desc')->get();
     $feed = new Feed();
     $channel = new Channel();
     $channel->title($config->blog_title)->description($config->blog_description)->url(url('/'))->appendTo($feed);
     foreach ($posts as $post) {
         $item = new Item();
         $item->title($post->title)->description($parsedown->parse($post->content))->url(url("/articles/{$post->slug}"))->guid(url("/articles/{$post->slug}"), true)->appendTo($channel);
     }
     return response($feed)->header('Content-Type', 'application/rss+xml');
 }
Exemplo n.º 8
0
$others = 0;
$withdrawals = 0;
$refunds = 0;
$sales = 0;
$initial = 0;
$creditSales = 0;
$creditPayments = 0;
if ($cashbox) {
    $transactions = CashboxTransaction::where('CashboxId', '=', $cashbox->Id)->get();
    // Count the initial cash.
    $bills = json_decode($cashbox->Open);
    foreach ($bills as $bill => $amount) {
        if ($bill != 'dollar') {
            $cash += $bill * $amount;
        } else {
            $cash += Configuration::find(0)->Dollar * $amount;
        }
    }
    $initial = $cash;
    // Now count all the other transactions.
    foreach ($transactions as $transaction) {
        switch ($transaction->Type) {
            case 1:
                $sales += $transaction->Amount;
                // Check if a credit card was used for sale.
                if (Sale::where('TransactionId', '=', $transaction->Id)->first()->Card) {
                    $card += $transaction->Amount;
                } else {
                    $cash += $transaction->Amount;
                }
                break;
Exemplo n.º 9
0
 /**
  * Function that makes a reservation.
  *
  * @return Response
  */
 public function makeReservation()
 {
     // Validate Input.
     $validator = Validator::make(Input::all(), array('items' => 'required', 'institution' => 'required', 'discount' => 'required', 'reservationAmount' => 'required'));
     if ($validator->fails()) {
         return response()->json(['error' => 'No se envio la informacion completa!']);
     }
     // 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 user branch.
     $worker = Worker::find(Auth::user()->TypeId);
     $userBranch = $worker->BranchId;
     $reservationPrice = 0;
     $branch = Branch::find($userBranch);
     // Get the user's cashbox.
     $cashbox = Cashbox::where('UserId', '=', Auth::user()->Id)->where('Close', '=', NULL)->first();
     // Check that we actually have a cashbox open.
     if (!$cashbox) {
         $response['state'] = 'Error';
         $response['error'] = 'La caja no esta abierta o por lo tanto no se puede realizar la reservacion!';
         return response()->json($response);
     }
     // Check discount is not greater than what user is allowed.
     $permissions = json_decode(UserLevel::find(Auth::user()->UserLevel)->Permissions);
     if (Input::get('discount') > $permissions->permissions->sales->discount->limit) {
         // Check if we have an auth code we can use.
         if (Input::get('authCode') == 0) {
             $response['state'] = 'Error';
             $response['error'] = 'No tiene permiso para otorgar este descuento!';
             return response()->json($response);
         }
         $request = Request::find(Input::get('authCode'));
         if ($request->Used == 1) {
             $response['state'] = 'Error';
             $response['error'] = 'No tiene permiso para otorgar este descuento!';
             return response()->json($response);
         }
         if ($request->Amount != Input::get('discount')) {
             $response['state'] = 'Error';
             $response['error'] = 'No tiene permiso para otorgar este descuento!';
             return response()->json($response);
         }
         $request->Used = 1;
         $request->save();
     }
     // Get client.
     $client = Client::where('Cedula', '=', Input::get('client'))->first();
     // Get institution if defined.
     $institution;
     if (Input::get('institution') != 0) {
         $institution = Institution::find(Input::get('institution'));
         if (!$institution) {
             $response['state'] = 'Error';
             $response['error'] = 'La institucion definida no fue encontrada en el sistema!';
             return response()->json($response);
         }
     }
     // Loop through products and services and get prices.
     $items = json_decode(Input::get('items'));
     foreach ($items as $code => $info) {
         // Check if it is a product.
         $product = Stock::where('Code', '=', $code)->where('BranchId', '=', $userBranch)->first();
         if (!$product) {
             // Check if it is a service.
             $service = Service::where('Code', '=', $code)->where('BranchId', '=', $userBranch)->first();
             if (!$service) {
                 $response['state'] = 'Error';
                 $response['error'] = 'No se reconocio uno de los productos o servicios!';
                 return response()->json($response);
             }
             // Add price to total of quotation.
             $reservationPrice += $service->Price * $info->quantity;
         } else {
             // Add price to total of quotation.
             $reservationPrice += $product->Price * $info->quantity;
         }
     }
     $subTotal = $reservationPrice;
     $discount = $reservationPrice * (Input::get('discount') / 100);
     // Give discount.
     $reservationPrice = $reservationPrice * (1 - Input::get('discount') / 100);
     // Calculate tax if required.
     $tax = 0;
     if (json_decode($branch->DefaultExpenses)->regimen == 'cuotageneral') {
         if (Input::get('institution') != 0) {
             if (!$institution->Excempt) {
                 $tax = $salePrice * 0.15;
             }
         } else {
             if (!$client || !$client->Excempt) {
                 $tax = $salePrice * 0.15;
             }
         }
     }
     // Save client information.
     $clientInfo = array();
     if (Input::get('institution') != 0) {
         // Save institution information.
         $clientInfo = array('Name' => $institution->Name, 'Address' => $institution->Address, 'Id' => $institution->RUC);
     } else {
         // Save institution information.
         if ($client) {
             $clientInfo = array('Name' => $client->Name, 'Address' => $client->Address, 'Id' => $client->Cedula);
         }
     }
     // Get reservation info.
     $config = Configuration::find(0);
     // Check that the deposit covers the minimum.
     if (Input::get('reservationAmount') < $config->Dollar * $config->MinimumReservation) {
         $response['state'] = 'Error';
         $response['error'] = 'El deposito minimo para realizar la reservacion es de ' . $config->Dollar * $config->MinimumReservation . ' Cordobas o ' . $config->MinimumReservation . ' Dolares Americanos.';
         return response()->json($response);
     }
     // Make Reservation.
     $reservation;
     if (Input::get('institution') != 0) {
         // Creditor Type 1 = Client, 2 = Institution.
         $reservation = Reservation::create(array('WorkerId' => $worker->Id, 'Value' => $reservationPrice, 'Discount' => Input::get('discount'), 'Tax' => $tax, 'CreditorId' => Input::get('institution'), 'CreditorType' => 2, 'TransactionId' => 0, 'State' => 'fresh', 'Life' => $config->ReservationLife, 'Deposit' => Input::get('reservationAmount')));
     } else {
         if (!$client) {
             $reservation = Reservation::create(array('WorkerId' => $worker->Id, 'Value' => $reservationPrice, 'Discount' => Input::get('discount'), 'Tax' => $tax, 'CreditorId' => 0, 'CreditorType' => 1, 'TransactionId' => 0, 'State' => 'fresh', 'Life' => $config->ReservationLife, 'Deposit' => Input::get('reservationAmount')));
         } else {
             $reservation = Reservation::create(array('WorkerId' => $worker->Id, 'Value' => $reservationPrice, 'Discount' => Input::get('discount'), 'Tax' => $tax, 'CreditorId' => $client->Id, 'CreditorType' => 1, 'TransactionId' => 0, 'State' => 'fresh', 'Life' => $config->ReservationLife, 'Deposit' => Input::get('reservationAmount')));
         }
     }
     // Now that the reservation has been created, create the transaction for it.
     $transaction = CashboxTransaction::create(array('CashboxId' => $cashbox->Id, 'DateTime' => date('Y-m-d H:i:s'), 'Type' => 9, 'Amount' => Input::get('reservationAmount'), 'Reason' => 'Deposito de Reservacion: ' . $reservation->Id . '.'));
     $reservation->TransactionId = $transaction->Id;
     $reservation->save();
     // Loop through items and add them to Reservation Breakdown.
     foreach ($items as $code => $info) {
         // Check if product.
         $product = Stock::where('Code', '=', $code)->where('BranchId', '=', $userBranch)->first();
         if (!$product) {
             // Get service cost.
             $service = Service::where('Code', '=', $code)->where('BranchId', '=', $userBranch)->first();
             ReservationBreakdown::create(array('ReservationId' => $reservation->Id, 'Code' => $code, 'Quantity' => $info->quantity, 'Price' => $service->Price));
         } else {
             ReservationBreakdown::create(array('ReservationId' => $reservation->Id, 'Code' => $code, 'Quantity' => $info->quantity, 'Price' => $product->Price));
         }
     }
     // Return success message and return quotation information.
     $response['state'] = 'Success';
     $response['reservationInfo'] = array('SubTotal' => $subTotal, 'Discount' => $discount, 'Tax' => $tax, 'Total' => $reservationPrice + $tax, 'ReservationId' => $reservation->Id, 'Date' => date('d/m/Y'), 'Life' => $config->ReservationLife, 'Deposit' => Input::get('reservationAmount'));
     $response['clientInfo'] = $clientInfo;
     return response()->json($response);
 }
Exemplo n.º 10
0
 /**
  * Function that gets reservation information.
  *
  * @return Response
  */
 public function getReservationData()
 {
     // Validate Input.
     $validator = Validator::make(Input::all(), array('id' => 'required'));
     if ($validator->fails()) {
         return response()->json(['error' => 'No se recibieron los datos necesarios!']);
     }
     // 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 user branch.
     $worker = Worker::find(Auth::user()->TypeId);
     $userBranch = $worker->BranchId;
     // Get the reservation.
     $reservation = Reservation::find(Input::get('id'));
     // Get the breakdown of the reservation.
     $reservationBreakdown = ReservationBreakdown::where('ReservationId', '=', $reservation->Id)->get();
     $reservationItems = array();
     foreach ($reservationBreakdown as $breakdown) {
         // Try getting the product.
         $product = Stock::where('Code', '=', $breakdown->Code)->where('BranchId', '=', $userBranch)->first();
         if (!$product) {
             // If it's not a product it's a service.
             $service = Service::where('Code', '=', $breakdown->Code)->where('BranchId', '=', $userBranch)->first();
             array_push($reservationItems, array('quantity' => $breakdown->Quantity, 'description' => $service->Description, 'price' => $service->Price));
         } else {
             array_push($reservationItems, array('quantity' => $breakdown->Quantity, 'note' => $product->Description, 'price' => $product->Price));
         }
     }
     // Get the client's or institution's information.
     $client;
     if ($reservation->CreditorId != 0) {
         if ($reservation->CreditorType != 1) {
             $temp = Institution::find($reservation->CreditorId);
             $client = array('Name' => $temp->Name, 'Address' => $temp->Address, 'Id' => $temp->RUC);
         } else {
             $temp = Client::find($reservation->CreditorId);
             $client = array('Name' => $temp->Name, 'Address' => $temp->Address, 'Id' => $temp->Id);
         }
     } else {
         $client = array('Name' => 'No asignado', 'Address' => 'No asignado', 'Id' => 'No asignado');
     }
     // Get configuration info.
     $config = Configuration::find(0);
     //  Now prepare all the information to be returned to user.
     $response['state'] = 'Success';
     $response['clientInfo'] = $client;
     $response['reservationInfo'] = array('Date' => date('Y-m-d', strtotime($reservation->Created)), 'Life' => $config->ReservationLife, 'ReservationId' => $reservation->Id, 'SubTotal' => $reservation->Value, 'Discount' => $reservation->Discount, 'Tax' => $reservation->Tax, 'Deposit' => $reservation->Deposit, 'Total' => $reservation->Value + $reservation->Tax - $reservation->Discount);
     $response['reservationItems'] = $reservationItems;
     // Return response.
     return response()->json($response);
 }
Exemplo n.º 11
0
 /**
  * Show the form for editing the specified resource.
  * GET /companies/{id}/edit
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $company = $this->company = Company::with('Address')->with('Currency')->findOrFail(intval(Configuration::get('DEF_COMPANY')));
     return View::make('companies.edit', compact('company'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     die(Input::get('tab_index'));
     $input = Input::all();
     // STEP 1 : validate data (pendding)
     $validator = Validator::make($input, Customer::$rules);
     if (!$validator->passes()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     // STEP 2 : build objects
     // Customer Stuff
     $customerData = array();
     $customerData['name_fiscal'] = $input['name_fiscal'];
     //		$customerData['name_commercial'] = $input['name_commercial'];
     //      $customerData['firstname']       = $input['firstname'];
     //      $customerData['lastname']        = $input['lastname'];
     //      $customerData['email']           = $input['email'];
     $customerData['website'] = Input::get('website', '');
     $customerData['identification'] = Input::get('identification', '');
     //      $customerData['phone']           = $input['phone'];
     //      $customerData['phone_mobile']    = $input['phone_mobile'];
     //      $customerData['fax']             = $input['fax'];
     $customerData['outstanding_amount_allowed'] = Input::get('outstanding_amount_allowed', Configuration::get('DEF_OUTSTANDING_AMOUNT'));
     $customerData['outstanding_amount'] = 0;
     $customerData['unresolved_amount'] = 0;
     $customerData['notes'] = Input::get('notes', '');
     $customerData['accept_einvoice'] = Input::get('accept_einvoice', 0);
     $customerData['accept_einvoice'] = intval($customerData['accept_einvoice']) > 0 ? 1 : 0;
     $customerData['blocked'] = 0;
     $customerData['active'] = Input::get('activce', 1);
     $customerData['active'] = intval($customerData['active']) > 0 ? 1 : 0;
     // Customer Relations!
     $customerData['salesrep_id'] = 0;
     $customerData['currency_id'] = 0;
     $customerData['customer_group_id'] = 0;
     $customerData['payment_method_id'] = 0;
     $customerData['sequence_id'] = 0;
     $customerData['carrier_id'] = 0;
     $customerData['price_list_id'] = 0;
     $customerData['direct_debit_account_id'] = 0;
     $customerData['invoicing_address_id'] = 0;
     $customerData['shipping_address_id'] = 0;
     // Addresses Stuff
     $addressInvData = array();
     $addressInvData['alias'] = 'Dirección Principal';
     $addressInvData['model_name'] = 'Customer';
     $addressInvData['name_commercial'] = Input::get('name_commercial', '');
     $addressInvData['address1'] = Input::get('address1', '');
     $addressInvData['address2'] = Input::get('address2', '');
     $addressInvData['postcode'] = Input::get('postcode', '');
     $addressInvData['city'] = Input::get('city', '');
     $addressInvData['state'] = Input::get('state', '');
     $addressInvData['country'] = Input::get('country', Configuration::get('DEF_COUNTRY_NAME'));
     $addressInvData['firstname'] = Input::get('firstname', '');
     $addressInvData['lastname'] = Input::get('lastname', '');
     $addressInvData['email'] = Input::get('email', '');
     $addressInvData['phone'] = Input::get('phone', '');
     $addressInvData['phone_mobile'] = Input::get('phone_mobile', '');
     $addressInvData['fax'] = Input::get('fax', '');
     $addressInvData['notes'] = '';
     $addressInvData['active'] = 1;
     $addressInvData['latitude'] = 0;
     $addressInvData['longitude'] = 0;
     // Address Relations!
     $addressInvData['owner_id'] = 0;
     $addressInvData['state_id'] = 0;
     $addressInvData['country_id'] = 0;
     $addressShipData = array();
     //		$addressShipData[''] = $input['ship_address_'];
     $customer = Customer::create($customerData);
     $addressInv = Address::create($addressInvData);
     $addressInv->Customer()->associate($customer);
     $customer->addresses()->save($addressInv);
     $customer->invoicing_address_id = $addressInv->id;
     $customer->shipping_address_id = $addressInv->id;
     $customer->save();
     // $customer->touch();
     // See: http://stackoverflow.com/questions/16740973/one-to-many-relationship-inserts-2-records-into-table
     // Kind of different...
     /*
                 return Redirect::route('customers.create')
     		->withInput()
     		->with('message_error', 'Esta txuta!');
     */
     // return Redirect::to('customers/' . $customer->id . '/edit')
     return Redirect::to('customers')->with('success', 'El Cliente se ha creado correctamente.');
     // return Redirect::route('customers.create')
     //        ->with('message_error', 'Esta txuta!');
     /*
             $v = Validator::make($input, Customer::$rules);
     
             if ($v->passes())
             {
                 $this->customer->create($input);
     
                 return Redirect::route('admin.customers.index')
     				->with('message_info', 'El registro se ha creado correctamente: '. $input['name'].' - '.$input['percent'].'%');
             }
     
             return Redirect::route('admin.customers.create')
                 ->withInput()
                 ->withErrors($v)
                 ->with('message_error', 'There were validation errors');
     */
 }
Exemplo n.º 13
0
 /**
  * Function that saves general configuration.
  *
  * @return Response
  */
 public function saveGeneral()
 {
     // Validate Input.
     $validator = Validator::make(Input::all(), array('dollar' => 'required', 'ruc' => 'required', 'quoteLife' => 'required', 'reservationLife' => 'required', 'minimumReservation' => 'required', 'pos' => 'required', 'pointsEnabled' => '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());
     }
     $pPercentage = Input::get('pointsPercentage') != null ? Input::get('pointsPercentage') : 0;
     $config = Configuration::find(0);
     $config->Dollar = Input::get('dollar');
     $config->RUC = Input::get('ruc');
     $config->QuoteLife = Input::get('quoteLife');
     $config->ReservationLife = Input::get('reservationLife');
     $config->MinimumReservation = Input::get('minimumReservation');
     $config->CityCoverage = Input::get('cityCoverage');
     $config->POS = Input::get('pos');
     $config->PointsEnabled = Input::get('pointsEnabled');
     $config->PointsPercentage = $pPercentage;
     $config->save();
     $response['state'] = 'Success';
     $response['message'] = 'Configuracion general guardada exitosamente!';
     return response()->json($response);
 }
Exemplo n.º 14
0
<?php

use App\Branch;
use App\Worker;
use App\UserLevel;
use App\Configuration;
// Get current branch.
$branch = Branch::find(Worker::find(Auth::user()->TypeId)->BranchId);
$levels = UserLevel::all();
$config = Configuration::find(0);
?>
<script src="{{ URL::to('/') }}/js/admin/configuration.js"></script>
<div class="hideable hide" id="configuracion">
  <div class="subnavbar">
    <div class="subnavbar-inner">
      <div class="container">
        <ul class="mainnav eirene-subnav">
          <li class="active"><a href="#configuracion-expenses"><i class="icon-money"></i><span>Gastos Fijos</span></a></li>
          <li><a href="#configuracion-permissions"><i class="icon-key"></i><span>Permisos para Usuarios</span> </a></li>
          <li><a href="#configuracion-general"><i class="icon-list-alt"></i><span>Configuracion General</span> </a></li>
        </ul>
      </div>
      <!-- /container --> 
    </div>
    <!-- /subnavbar-inner --> 
  </div>
  <div class="container">
    <div class="row v-offset-2">
    </div>
    <div class="main sub-hideable" id="configuracion-expenses">
      <div class="main-inner">
Exemplo n.º 15
0
Route::group(['middleware' => 'auth'], function () {
    // Route::get( 'contact', 'ContactMessagesController@create');
    Route::post('contact', 'ContactMessagesController@store');
    // See: https://gist.github.com/drawmyattention/8cb599ee5dc0af5f4246
    Route::group(array('middleware' => 'authAdmin'), function () {
        Route::resource('companies', 'CompaniesController');
        Route::resource('configurations', 'ConfigurationsController');
        Route::resource('configurationkeys', 'ConfigurationKeysController');
        Route::resource('languages', 'LanguagesController');
        //		Route::resource('sequences', 'SequencesController');
        Route::resource('users', 'UsersController');
        //		Route::resource('templates', 'TemplatesController');
        Route::resource('currencies', 'CurrenciesController');
        Route::resource('taxes', 'TaxesController');
        Route::resource('categories', 'CategoriesController');
        Route::resource('products', 'ProductsController');
        Route::post('products/{id}/combine', array('as' => 'products.combine', 'uses' => 'ProductsController@combine'));
        Route::get('products/ajax/name_lookup', array('uses' => 'ProductsController@ajaxProductSearch', 'as' => 'products.ajax.nameLookup'));
        Route::post('products/ajax/options_lookup', array('uses' => 'ProductsController@ajaxProductOptionsSearch', 'as' => 'products.ajax.optionsLookup'));
        Route::resource('optiongroups', 'OptionGroupsController');
        Route::resource('optiongroups.options', 'OptionsController');
        Route::resource('combinations', 'CombinationsController');
        Route::resource('warehouses', 'WarehousesController');
        Route::resource('stockmovements', 'StockMovementsController');
    });
});
/* ********************************************************** */
Route::get('test', function () {
    echo \Carbon\Carbon::now();
    echo Config::get('app.timezone') . \App\Configuration::get('TIMEZONE');
});
Exemplo n.º 16
0
 /**
  * Delete a configuration key in database 
  *
  * @param string $key Key to delete
  * @return boolean Deletion result
  */
 public static function deleteByName($key)
 {
     // If the key is invalid or if it does not exists, do nothing.
     // if (!Validate::isConfigName($key))
     // 	return false;
     /* Delete the key from the main configuration table */
     // if (Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'configuration` WHERE `id_configuration` = '.(int)self::$_CONF_IDS[$key].' LIMIT 1'))
     // 	unset(self::$_CONF[$key]);		// self::$_CONF = null;
     // else
     // 	return false;
     $model = Configuration::where('name', '=', $key)->firstOrFail();
     if ($model->delete()) {
         unset(self::$_CONF[$key]);
     } else {
         return false;
     }
     return true;
 }
Exemplo n.º 17
0
 /**
  * Function that gets contract payments table.
  *
  * @return Response
  */
 public function contractInfo()
 {
     // Validate Input.
     $validator = Validator::make(Input::all(), array('id' => 'required'));
     if ($validator->fails()) {
         return response()->json(['error' => 'No se recibieron los datos necesarios!']);
     }
     // 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 user branch.
     $worker = Worker::find(Auth::user()->TypeId);
     $userBranch = $worker->BranchId;
     // Get the contract.
     $contract = Contract::find(Input::get('id'));
     // Get the breakdown of the contract.
     $contractBreakdown = ContractBreakdown::where('ContractId', '=', $contract->Id)->get();
     $contractServices = array();
     foreach ($contractBreakdown as $breakdown) {
         // Try getting the product.
         $product = Stock::where('Code', '=', $breakdown->Code)->where('BranchId', '=', $userBranch)->first();
         if (!$product) {
             // If it's not a product it's a service.
             $service = Service::where('Code', '=', $breakdown->Code)->where('BranchId', '=', $userBranch)->first();
             array_push($contractServices, array('quantity' => $breakdown->Quantity, 'note' => $service->Note));
         } else {
             array_push($contractServices, array('quantity' => $breakdown->Quantity, 'note' => $product->Description));
         }
     }
     // Get the branch.
     $branch = Branch::find($userBranch);
     // Get the client's information.
     $client = Client::find($contract->ClientId);
     // Get the configuration information.
     $config = Configuration::find(0);
     //  Now prepare all the information to be returned to user.
     $response['state'] = 'Success';
     $response['name'] = $client->Name;
     $response['ocupation'] = $client->Ocupation;
     $response['address'] = $client->Address;
     $response['cedula'] = $client->Cedula;
     $response['debt'] = $contract->Debt;
     $response['span'] = floor($contract->Debt / $contract->Quota);
     $response['quota'] = $contract->Quota;
     $response['interval'] = $contract->QuotaInterval;
     $response['paymentDates'] = explode(',', $contract->PaymentDates);
     $response['startDate'] = $contract->StartDate;
     $response['createDate'] = date('Y-m-d', strtotime($contract->Created));
     $response['interest'] = $contract->Interest;
     $response['branchAddress'] = $branch->Address;
     $response['cityCoverage'] = $config->CityCoverage;
     $response['contractServices'] = $contractServices;
     // Return response.
     return response()->json($response);
 }
Exemplo n.º 18
0
 /**
  * Display the specified resource.
  *
  * @param  string  $slug
  * @return \Illuminate\Http\Response
  */
 public function show($slug)
 {
     $configuration = Configuration::find(1);
     $post = Post::where('slug', $slug)->first();
     return view('posts.show', ['post' => $post, 'configuration' => $configuration]);
 }
Exemplo n.º 19
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     /*
     |--------------------------------------------------------------------------
     | Application Configuration
     |--------------------------------------------------------------------------
     |
     | Load Configuration Keys.
     |
     */
     Configuration::loadConfiguration();
     if (Auth::check()) {
         $user = User::with('language')->find(Auth::id());
         // $email = Auth::user()->email;
         $language = $user->language;
     } else {
         $user = NULL;
         $language = Language::find(intval(Request::cookie('user_language')));
         if (!$language) {
             $language = Language::findOrFail(intval(Configuration::get('DEF_LANGUAGE')));
         }
     }
     $company = Company::with('currency')->findOrFail(intval(Configuration::get('DEF_COMPANY')));
     Context::getContext()->user = $user;
     Context::getContext()->language = $language;
     Context::getContext()->company = $company;
     Context::getContext()->currency = $company->currency;
     Context::getContext()->controller = $request->segment(1);
     if ($request->segment(3) == 'attributes') {
         Context::getContext()->controller = $request->segment(3);
     }
     Context::getContext()->action = NULL;
     //$action;
     /* * /
     		// echo_r($request->route()->getAction());
     		// http://laravel.io/forum/10-15-2014-laravel-5-passing-parameters-to-middleware-handlers
     		// http://www.codeheaps.com/php-programming/laravel-5-middleware-stack-decoded/
     		// http://blog.elliothesp.co.uk/coding/passing-parameters-middleware-laravel-5/
     		// https://gist.github.com/dwightwatson/6200599
     		// http://stackoverflow.com/questions/26840278/laravel-5-how-to-get-route-action-name
     		    $action = $request->route()->getAction();
     		    $routeArray = Str::parseCallback($action['controller'], null);
     
     		    if (last($routeArray) != null) {
     		        // Remove 'controller' from the controller name.
     		        $controller = str_replace('Controller', '', class_basename(head($routeArray)));
     
     		        // Take out the method from the action.
     		        $action = str_replace(['get', 'post', 'patch', 'put', 'delete'], '', last($routeArray));
     
     		        // return Str::slug($controller . '-' . $action);
     		    } else {
     		        // return 'closure';
     		        $controller = 'closure';
     		        $action = '';
     		    }
     		// gist ENDS
     
     		Context::getContext()->controller = $controller;
     		Context::getContext()->action     = $action; 
     		echo Str::slug($controller . '-' . $action);
     / * */
     // Changing Timezone At Runtime. But this change does not seem to be taken by Carbon... Why?
     Config::set('app.timezone', Configuration::get('TIMEZONE'));
     // Changing The Default Language At Runtime
     App::setLocale(Context::getContext()->language->iso_code);
     return $next($request);
 }
Exemplo n.º 20
0
 public function refreshCashbox()
 {
     // Check if a cashbox is open and get all transactions, etc from it if there is.
     $cashbox = Cashbox::where('UserId', '=', Auth::user()->Id)->where('Close', '=', NULL)->first();
     if (!$cashbox) {
         $response['state'] = 'Error';
         $response['error'] = 'No hay una caja abierta y por lo tanto no se pudo actualizar los valores de la caja!';
         return response()->json($response);
     }
     $transactions = CashboxTransaction::where('CashboxId', '=', $cashbox->Id)->get();
     $cash = 0;
     $card = 0;
     $providers = 0;
     $staff = 0;
     $others = 0;
     $withdrawals = 0;
     $refunds = 0;
     $sales = 0;
     $initial = 0;
     $creditSales = 0;
     $creditPayments = 0;
     if ($cashbox) {
         // Count the initial cash.
         $bills = json_decode($cashbox->Open);
         foreach ($bills as $bill => $amount) {
             if ($bill != 'dollar') {
                 $cash += $bill * $amount;
             } else {
                 $cash += Configuration::find(0)->Dollar * $amount;
             }
         }
         $initial = $cash;
         // Now count all the other transactions.
         foreach ($transactions as $transaction) {
             switch ($transaction->Type) {
                 case 1:
                     $sales += $transaction->Amount;
                     // Check if a credit card was used for sale.
                     if (Sale::where('TransactionId', '=', $transaction->Id)->first()->Card) {
                         $card += $transaction->Amount;
                     } else {
                         $cash += $transaction->Amount;
                     }
                     break;
                 case 2:
                     $providers += $transaction->Amount;
                     break;
                 case 3:
                     $staff += $transaction->Amount;
                     break;
                 case 4:
                     $others += $transaction->Amount;
                     break;
                 case 5:
                     $withdrawals += $transaction->Amount;
                     break;
                 case 6:
                     $refunds += $transaction->Amount;
                     break;
                     // Contract Payments.
                 // Contract Payments.
                 case 7:
                     $sales += $transaction->Amount;
                     $cash += $transaction->Amount;
                     break;
                     // Credit sales.
                 // Credit sales.
                 case 8:
                     $creditSales += $transaction->Amount;
                     $sales += $transaction->Amount;
                     break;
                     // Deposits for reservations.
                 // Deposits for reservations.
                 case 9:
                     $sales += $transaction->Amount;
                     $cash += $transaction->Amount;
                     break;
                 case 10:
                     $creditPayments += $transaction->Amount;
                     $cash += $transaction->Amount;
                     break;
             }
         }
         $total = $initial + $sales + $refunds + $creditPayments - $providers - $staff - $withdrawals - $others - $creditSales;
         $cash = $cash + $refunds + $creditPayments - $providers - $staff - $withdrawals - $others;
         // Inform user operation was completed succesfully.
         $response['state'] = 'Success';
         $response['total'] = $total;
         $response['cash'] = $cash;
         $response['card'] = $card;
         $response['providers'] = $providers;
         $response['staff'] = $staff;
         $response['others'] = $others;
         $response['withdrawals'] = $withdrawals;
         $response['refunds'] = $refunds;
         $response['sales'] = $sales;
         $response['creditPayments'] = $creditPayments;
         $response['creditSales'] = $creditSales;
         return response()->json($response);
     }
 }