app/Http/Controllers/SellController.php
/**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
Show the form for creating a new resource.
@return \Illuminate\Http\Response
Show the form for creating a new resource . @return \ Illuminate \ Http \ Response
public function create()
    {
        if (!auth()->user()->can('direct_sell.access')) {
            abort(403, 'Unauthorized action.');
        }
        $business_id = request()->session()->get('user.business_id');
        if (!$this->moduleUtil->isSubscribed($business_id)) {
            return $this->moduleUtil->expiredResponse();
        } elseif (!$this->moduleUtil->isQuotaAvailable('invoices', $business_id)) {
            return $this->moduleUtil->quotaExpiredResponse('invoices', $business_id, action('SellController@index'));
        }
        $walk_in_customer = $this->contactUtil->getWalkInCustomer($business_id);
        $business_details = $this->businessUtil->getDetails($business_id);
        $taxes = TaxRate::forBusinessDropdown($business_id, true, true);
        $business_locations = BusinessLocation::forDropdown($business_id, false, true);
        $bl_attributes = $business_locations['attributes'];
        $business_locations = $business_locations['locations'];
        $default_location = null;
        if (count($business_locations) == 1) {
            foreach ($business_locations as $id => $name) {
                $default_location = $id;
            }
        }
        $commsn_agnt_setting = $business_details->sales_cmsn_agnt;
        $commission_agent = [];
        if ($commsn_agnt_setting == 'user') {
            $commission_agent = User::forDropdown($business_id);
        } elseif ($commsn_agnt_setting == 'cmsn_agnt') {
            $commission_agent = User::saleCommissionAgentsDropdown($business_id);
        }
        $types = [];
        if (auth()->user()->can('supplier.create')) {
            $types['supplier'] = __('report.supplier');
        }
        if (auth()->user()->can('customer.create')) {
            $types['customer'] = __('report.customer');
        }
        if (auth()->user()->can('supplier.create') && auth()->user()->can('customer.create')) {
            $types['both'] = __('lang_v1.both_supplier_customer');
        }
        $customer_groups = CustomerGroup::forDropdown($business_id);
        $customer_areas = DB::table('KW_AREA')->get();
        $payment_line = $this->dummyPaymentLine;
        $payment_types = $this->transactionUtil->payment_types();
        $price_groups = SellingPriceGroup::forDropdown($business_id);
        $default_datetime = $this->businessUtil->format_date('now', true);
        $pos_settings = empty($business_details->pos_settings) ? $this->businessUtil->defaultPosSettings() : json_decode($business_details->pos_settings, true);
        $invoice_schemes = InvoiceScheme::forDropdown($business_id);
        $default_invoice_schemes = InvoiceScheme::getDefault($business_id);
        $shipping_statuses = $this->transactionUtil->shipping_statuses();
        $types_of_service = [];
        if ($this->moduleUtil->isModuleEnabled('types_of_service')) {
            $types_of_service = TypesOfService::forDropdown($business_id);
        }
        $accounts = [];
        if ($this->moduleUtil->isModuleEnabled('account')) {
            $accounts = Account::forDropdown($business_id, true, false);
        }
        return view('sell.create')
            ->with(compact(
                'business_details',
                'taxes',
                'walk_in_customer',
                'business_locations',
                'bl_attributes',
                'default_location',
                'commission_agent',
                'types',
                'customer_groups',
                'payment_line',
                'payment_types',
                'price_groups',
                'default_datetime',
                'pos_settings',
                'invoice_schemes',
                'default_invoice_schemes',
                'types_of_service',
                'accounts',
                'shipping_statuses',
                'customer_areas'
            ));
    }
public function create ( ) { if ( ! auth ( ) -> user ( ) -> can ( 'direct_sell.access' ) ) { abort ( 403 , 'Unauthorized action.' ) ; } $ business_id = request ( ) -> session ( ) -> get ( 'user.business_id' ) ; if ( ! $ this -> moduleUtil -> isSubscribed ( $ business_id ) ) { return $ this -> moduleUtil -> expiredResponse ( ) ; } elseif ( ! $ this -> moduleUtil -> isQuotaAvailable ( 'invoices' , $ business_id ) ) { return $ this -> moduleUtil -> quotaExpiredResponse ( 'invoices' , $ business_id , action ( 'SellController@index' ) ) ; } $ walk_in_customer = $ this -> contactUtil -> getWalkInCustomer ( $ business_id ) ; $ business_details = $ this -> businessUtil -> getDetails ( $ business_id ) ; $ taxes = TaxRate :: forBusinessDropdown ( $ business_id , true , true ) ; $ business_locations = BusinessLocation :: forDropdown ( $ business_id , false , true ) ; $ bl_attributes = $ business_locations [ 'attributes' ] ; $ business_locations = $ business_locations [ 'locations' ] ; $ default_location = null ; if ( count ( $ business_locations ) == 1 ) { foreach ( $ business_locations as $ id => $ name ) { $ default_location = $ id ; } } $ commsn_agnt_setting = $ business_details -> sales_cmsn_agnt ; $ commission_agent = [ ] ; if ( $ commsn_agnt_setting == 'user' ) { $ commission_agent = User :: forDropdown ( $ business_id ) ; } elseif ( $ commsn_agnt_setting == 'cmsn_agnt' ) { $ commission_agent = User :: saleCommissionAgentsDropdown ( $ business_id ) ; } $ types = [ ] ; if ( auth ( ) -> user ( ) -> can ( 'supplier.create' ) ) { $ types [ 'supplier' ] = __ ( 'report.supplier' ) ; } if ( auth ( ) -> user ( ) -> can ( 'customer.create' ) ) { $ types [ 'customer' ] = __ ( 'report.customer' ) ; } if ( auth ( ) -> user ( ) -> can ( 'supplier.create' ) && auth ( ) -> user ( ) -> can ( 'customer.create' ) ) { $ types [ 'both' ] = __ ( 'lang_v1.both_supplier_customer' ) ; } $ customer_groups = CustomerGroup :: forDropdown ( $ business_id ) ; $ customer_areas = DB :: table ( 'KW_AREA' ) -> get ( ) ; $ payment_line = $ this -> dummyPaymentLine ; $ payment_types = $ this -> transactionUtil -> payment_types ( ) ; $ price_groups = SellingPriceGroup :: forDropdown ( $ business_id ) ; $ default_datetime = $ this -> businessUtil -> format_date ( 'now' , true ) ; $ pos_settings = empty ( $ business_details -> pos_settings ) ? $ this -> businessUtil -> defaultPosSettings ( ) : json_decode ( $ business_details -> pos_settings , true ) ; $ invoice_schemes = InvoiceScheme :: forDropdown ( $ business_id ) ; $ default_invoice_schemes = InvoiceScheme :: getDefault ( $ business_id ) ; $ shipping_statuses = $ this -> transactionUtil -> shipping_statuses ( ) ; $ types_of_service = [ ] ; if ( $ this -> moduleUtil -> isModuleEnabled ( 'types_of_service' ) ) { $ types_of_service = TypesOfService :: forDropdown ( $ business_id ) ; } $ accounts = [ ] ; if ( $ this -> moduleUtil -> isModuleEnabled ( 'account' ) ) { $ accounts = Account :: forDropdown ( $ business_id , true , false ) ; } return view ( 'sell.create' ) -> with ( compact ( 'business_details' , 'taxes' , 'walk_in_customer' , 'business_locations' , 'bl_attributes' , 'default_location' , 'commission_agent' , 'types' , 'customer_groups' , 'payment_line' , 'payment_types' , 'price_groups' , 'default_datetime' , 'pos_settings' , 'invoice_schemes' , 'default_invoice_schemes' , 'types_of_service' , 'accounts' , 'shipping_statuses' , 'customer_areas' ) ) ; }
Show the form for creating a new resource.
Show the form for creating a new resource .
//Check if subscribed or not, then check for users quota //Selling Price Group Dropdown //Types of service //Accounts