Beispiel #1
0
 public function createCode($name, $numb = 0)
 {
     $code = substr($name, $numb, 3);
     $already = Supplier::where('code', $code)->first();
     if ($already) {
         return $this->createCode($name, $numb + 1);
     }
     return $code;
 }
 public static function furnizori()
 {
     $out = [];
     $data = Supplier::where('type', '=', 1)->get()->toArray();
     foreach ($data as $k => $d) {
         $out[$d['id']] = $d['name'];
     }
     return $out;
 }
Beispiel #3
0
 public function furnizori()
 {
     $id_utilitate = Input::get('id');
     $out = [];
     $data = Supplier::where('type', $id_utilitate)->get()->toArray();
     foreach ($data as $k => $d) {
         $out[$d['id']] = $d['name'];
     }
     return ['options' => ['0' => count($out) > 0 ? '-- Selectati furnizor --' : '-- Nu are furnizor --'] + $out];
 }
 public function getReport(Request $request)
 {
     $customers = Customer::where('status', 1)->lists('name', 'id');
     $employees = Employee::where('status', 1)->lists('name', 'id');
     $suppliers = Supplier::where('status', 1)->lists('company_name', 'id');
     $cashInHand = DB::table('workspace_ledgers')->where(['account_code' => 11000, 'balance_type' => Config::get('common.balance_type_intermediate'), 'year' => CommonHelper::get_current_financial_year()])->sum('balance');
     $sales = DB::table('general_journals')->select('general_journals.*', 'chart_of_accounts.name', 'sales_order.customer_id', 'sales_order.customer_type')->join('chart_of_accounts', 'chart_of_accounts.code', '=', 'general_journals.account_code')->join('sales_order', 'sales_order.id', '=', 'general_journals.reference_id')->where(['transaction_type' => Config::get('common.transaction_type.sales'), 'account_code' => 31000, 'year' => CommonHelper::get_current_financial_year(), 'general_journals.status' => 1])->where('general_journals.date', '=', strtotime(date('d-m-Y')))->get();
     $salesReturns = DB::table('general_journals')->select('general_journals.*', 'chart_of_accounts.name', 'sales_order.customer_id', 'sales_order.customer_type')->join('chart_of_accounts', 'chart_of_accounts.code', '=', 'general_journals.account_code')->join('sales_order', 'sales_order.id', '=', 'general_journals.reference_id')->where(['transaction_type' => Config::get('common.transaction_type.sales_return'), 'account_code' => 32000, 'year' => CommonHelper::get_current_financial_year(), 'general_journals.status' => 1])->where('general_journals.date', '=', strtotime(date('d-m-Y')))->get();
     $expenses = DB::table('general_journals')->select('general_journals.*', 'chart_of_accounts.name')->join('chart_of_accounts', 'chart_of_accounts.code', '=', 'general_journals.account_code')->where('general_journals.account_code', 'like', '2%')->where('general_journals.date', '=', strtotime(date('d-m-Y')))->get();
     $sales = json_decode(json_encode($sales), true);
     $salesReturns = json_decode(json_encode($salesReturns), true);
     $expenses = json_decode(json_encode($expenses), true);
     $ajaxView = view('reports.cashFlow.view', compact('sales', 'salesReturns', 'expenses', 'customers', 'employees', 'suppliers', 'cashInHand'))->render();
     return response()->json($ajaxView);
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     $materialConfig = array_flip(Config::get('common.material_type'));
     $suppliers = Supplier::where('status', 1)->lists('company_name', 'id');
     $rmaterials = Material::where('status', 1)->where('type', '!=', $materialConfig['Discarded'])->select('name', 'id', 'type')->get();
     $materials = [];
     foreach ($rmaterials as $material) {
         if ($material->type != 1) {
             $materials[$material->id] = Config::get('common.material_type')[$material->type] . ' - ' . $material->name;
         } else {
             $materials[$material->id] = $material->name;
         }
     }
     $raw_stock = RawStock::lists('quantity', 'material_id');
     return view('purchasesReturn.create', compact('suppliers', 'materials', 'raw_stock'));
 }
Beispiel #6
0
 public static function getMainSuppliers()
 {
     $suppliers = Supplier::where('supplied_by', '>', 0)->get();
     $main_supplier_ids = $suppliers->unique('supplied_by')->pluck('supplied_by')->toArray();
     return Supplier::find($main_supplier_ids);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $filename = $this->argument('filename');
     if (!$this->option('testrun') == 'true') {
         $this->comment('======= Importing Licenses from ' . $filename . ' =========');
     } else {
         $this->comment('====== TEST ONLY License Import for ' . $filename . ' ====');
         $this->comment('============== NO DATA WILL BE WRITTEN ==============');
     }
     if (!ini_get("auto_detect_line_endings")) {
         ini_set("auto_detect_line_endings", '1');
     }
     $csv = Reader::createFromPath($this->argument('filename'));
     $csv->setNewline("\r\n");
     $csv->setOffset(1);
     $duplicates = '';
     // Loop through the records
     $nbInsert = $csv->each(function ($row) use($duplicates) {
         $status_id = 1;
         // Let's just map some of these entries to more user friendly words
         if (array_key_exists('0', $row)) {
             $user_name = trim($row[0]);
         } else {
             $user_name = '';
         }
         if (array_key_exists('1', $row)) {
             $user_email = trim($row[1]);
         } else {
             $user_email = '';
         }
         if (array_key_exists('2', $row)) {
             $user_username = trim($row[2]);
         } else {
             $user_username = '';
         }
         if (array_key_exists('3', $row)) {
             $user_license_name = trim($row[3]);
         } else {
             $user_license_name = '';
         }
         if (array_key_exists('4', $row)) {
             $user_license_serial = trim($row[4]);
         } else {
             $user_license_serial = '';
         }
         if (array_key_exists('5', $row)) {
             $user_licensed_to_name = trim($row[5]);
         } else {
             $user_licensed_to_name = '';
         }
         if (array_key_exists('6', $row)) {
             $user_licensed_to_email = trim($row[6]);
         } else {
             $user_licensed_to_email = '';
         }
         if (array_key_exists('7', $row)) {
             $user_license_seats = trim($row[7]);
         } else {
             $user_license_seats = '';
         }
         if (array_key_exists('8', $row)) {
             $user_license_reassignable = trim($row[8]);
             if ($user_license_reassignable != '') {
                 if (strtolower($user_license_reassignable) == 'yes' || strtolower($user_license_reassignable) == 'true' || $user_license_reassignable == '1') {
                     $user_license_reassignable = 1;
                 }
             } else {
                 $user_license_reassignable = 0;
             }
         } else {
             $user_license_reassignable = 0;
         }
         if (array_key_exists('9', $row)) {
             $user_license_supplier = trim($row[9]);
         } else {
             $user_license_supplier = '';
         }
         if (array_key_exists('10', $row)) {
             $user_license_maintained = trim($row[10]);
             if ($user_license_maintained != '') {
                 if (strtolower($user_license_maintained) == 'yes' || strtolower($user_license_maintained) == 'true' || $user_license_maintained == '1') {
                     $user_license_maintained = 1;
                 }
             } else {
                 $user_license_maintained = 0;
             }
         } else {
             $user_license_maintained = '';
         }
         if (array_key_exists('11', $row)) {
             $user_license_notes = trim($row[11]);
         } else {
             $user_license_notes = '';
         }
         if (array_key_exists('12', $row)) {
             if ($row[12] != '') {
                 $user_license_purchase_date = date("Y-m-d 00:00:01", strtotime($row[12]));
             } else {
                 $user_license_purchase_date = '';
             }
         } else {
             $user_license_purchase_date = 0;
         }
         // A number was given instead of a name
         if (is_numeric($user_name)) {
             $this->comment('User ' . $user_name . ' is not a name - assume this user already exists');
             $user_username = '';
             // No name was given
         } elseif ($user_name == '') {
             $this->comment('No user data provided - skipping user creation, just adding license');
             $first_name = '';
             $last_name = '';
             $user_username = '';
         } else {
             $name = explode(" ", $user_name);
             $first_name = $name[0];
             $email_last_name = '';
             $email_prefix = $first_name;
             if (!array_key_exists(1, $name)) {
                 $last_name = '';
                 $email_last_name = $last_name;
                 $email_prefix = $first_name;
             } else {
                 $last_name = str_replace($first_name, '', $user_name);
                 if ($this->option('email_format') == 'filastname') {
                     $email_last_name .= str_replace(' ', '', $last_name);
                     $email_prefix = $first_name[0] . $email_last_name;
                 } elseif ($this->option('email_format') == 'firstname.lastname') {
                     $email_last_name .= str_replace(' ', '', $last_name);
                     $email_prefix = $first_name . '.' . $email_last_name;
                 } elseif ($this->option('email_format') == 'firstname') {
                     $email_last_name .= str_replace(' ', '', $last_name);
                     $email_prefix = $first_name;
                 }
             }
             $user_username = $email_prefix;
             // Generate an email based on their name if no email address is given
             if ($user_email == '') {
                 if ($first_name == 'Unknown') {
                     $status_id = 7;
                 }
                 $email = strtolower($email_prefix) . '@' . $this->option('domain');
                 $user_email = str_replace("'", '', $email);
             }
         }
         $this->comment('Full Name: ' . $user_name);
         $this->comment('First Name: ' . $first_name);
         $this->comment('Last Name: ' . $last_name);
         $this->comment('Username: '******'Email: ' . $user_email);
         $this->comment('License Name: ' . $user_license_name);
         $this->comment('Serial No: ' . $user_license_serial);
         $this->comment('Licensed To Name: ' . $user_licensed_to_name);
         $this->comment('Licensed To Email: ' . $user_licensed_to_email);
         $this->comment('Seats: ' . $user_license_seats);
         $this->comment('Reassignable: ' . $user_license_reassignable);
         $this->comment('Supplier: ' . $user_license_supplier);
         $this->comment('Maintained: ' . $user_license_maintained);
         $this->comment('Notes: ' . $user_license_notes);
         $this->comment('Purchase Date: ' . $user_license_purchase_date);
         $this->comment('------------- Action Summary ----------------');
         if ($user_username != '') {
             if ($user = User::where('username', $user_username)->whereNotNull('username')->first()) {
                 $this->comment('User ' . $user_username . ' already exists');
             } else {
                 $user = new \App\Models\User();
                 $password = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20);
                 $user->first_name = $first_name;
                 $user->last_name = $last_name;
                 $user->username = $user_username;
                 $user->email = $user_email;
                 $user->permissions = '{user":1}';
                 $user->password = bcrypt($password);
                 $user->activated = 1;
                 if ($user->save()) {
                     $this->comment('User ' . $first_name . ' created');
                 } else {
                     $this->error('ERROR CREATING User ' . $first_name . ' ' . $last_name);
                     $this->error($user->getErrors());
                 }
                 $this->comment('User ' . $first_name . ' created');
             }
         } else {
             $user = new User();
             $user->user_id = null;
         }
         // Check for the supplier match and create it if it doesn't exist
         if ($supplier = Supplier::where('name', $user_license_supplier)->first()) {
             $this->comment('Supplier ' . $user_license_supplier . ' already exists');
         } else {
             $supplier = new Supplier();
             $supplier->name = e($user_license_supplier);
             $supplier->user_id = 1;
             if ($supplier->save()) {
                 $this->comment('Supplier ' . $user_license_supplier . ' was created');
             } else {
                 $this->comment('Something went wrong! Supplier ' . $user_license_supplier . ' was NOT created');
             }
         }
         // Add the license
         $license = new License();
         $license->name = e($user_license_name);
         if ($user_license_purchase_date != '') {
             $license->purchase_date = $user_license_purchase_date;
         } else {
             $license->purchase_date = null;
         }
         $license->serial = e($user_license_serial);
         $license->seats = e($user_license_seats);
         $license->supplier_id = $supplier->id;
         $license->user_id = 1;
         if ($user_license_purchase_date != '') {
             $license->purchase_date = $user_license_purchase_date;
         } else {
             $license->purchase_date = null;
         }
         $license->license_name = $user_licensed_to_name;
         $license->license_email = $user_licensed_to_email;
         $license->notes = e($user_license_notes);
         if ($license->save()) {
             $this->comment('License ' . $user_license_name . ' with serial number ' . $user_license_serial . ' was created');
             $license_seat_created = 0;
             for ($x = 0; $x < $user_license_seats; $x++) {
                 // Create the license seat entries
                 $license_seat = new LicenseSeat();
                 $license_seat->license_id = $license->id;
                 // Only assign the first seat to the user
                 if ($x == 0) {
                     $license_seat->assigned_to = $user->id;
                 } else {
                     $license_seat->assigned_to = null;
                 }
                 if ($license_seat->save()) {
                     $license_seat_created++;
                 }
             }
             if ($license_seat_created > 0) {
                 $this->comment($license_seat_created . ' seats were created');
             } else {
                 $this->comment('Something went wrong! NO seats for ' . $user_license_name . ' were created');
             }
         } else {
             $this->comment('Something went wrong! License ' . $user_license_name . ' was NOT created');
         }
         $this->comment('=====================================');
         return true;
     });
 }
Beispiel #8
0
 /**
  * @return \Illuminate\Routing\Route|null|string
  */
 public function ingnoreId()
 {
     $id = $this->route('supplier');
     $name = $this->input('name');
     return Supplier::where(compact('id', 'name'))->exists() ? $id : '';
 }
Beispiel #9
0
 public function edit($id)
 {
     $salesOrder = SalesOrder::where('id', $id)->where('status', '!=', 4)->with(['salesOrderItems', 'salesOrderItems.product', 'salesOrderItems.salesDelivery'])->first();
     if ($salesOrder->customer_type == 1) {
         $customers = Employee::where('status', 1)->lists('name', 'id');
     } elseif ($salesOrder->customer_type == 2) {
         $customers = Supplier::where('status', 1)->lists('name', 'id');
     } else {
         $customers = Customer::where('status', 1)->lists('name', 'id');
     }
     if ($salesOrder->customer_id) {
         $personalAccount = PersonalAccount::where('person_id', '=', $salesOrder->customer_id)->where('person_type', '=', $salesOrder->customer_type)->first();
     }
     return view('sales.salesOrder.edit')->with(compact('salesOrder', 'customers', 'personalAccount'));
 }
 public function search(Request $request)
 {
     $arr = [];
     if ($request->has('q')) {
         $q = $request->input('q');
         $branchid = $request->input('branchid');
         $components = Component::where('descriptor', 'like', '%' . $q . '%')->orderBy('descriptor')->get(['descriptor', 'id']);
         foreach ($components as $component) {
             array_push($arr, ['table' => 'component', 'item' => $component->descriptor, 'id' => strtolower($component->id)]);
         }
         $compcats = Compcat::where('descriptor', 'like', '%' . $q . '%')->orderBy('descriptor')->get(['descriptor', 'id']);
         foreach ($compcats as $compcat) {
             array_push($arr, ['table' => 'compcat', 'item' => $compcat->descriptor, 'id' => strtolower($compcat->id)]);
         }
         $expenses = Expense::where('descriptor', 'like', '%' . $q . '%')->orderBy('descriptor')->get(['descriptor', 'id']);
         foreach ($expenses as $expense) {
             array_push($arr, ['table' => 'expense', 'item' => $expense->descriptor, 'id' => strtolower($expense->id)]);
         }
         $expscats = Expscat::where('descriptor', 'like', '%' . $q . '%')->orderBy('descriptor')->get(['descriptor', 'id']);
         foreach ($expscats as $expscat) {
             array_push($arr, ['table' => 'expscat', 'item' => $expscat->descriptor, 'id' => strtolower($expscat->id)]);
         }
         $suppliers = Supplier::where('descriptor', 'like', '%' . $q . '%')->where('branchid', $branchid)->orderBy('descriptor')->get(['descriptor', 'id']);
         foreach ($suppliers as $supplier) {
             array_push($arr, ['table' => 'supplier', 'item' => $supplier->descriptor, 'id' => strtolower($supplier->id)]);
         }
         //$payments = ['110A573E855511E68FF47E841D02B37D'=>'cash', '19ADA60B855511E68FF47E841D02B37D'=>'check'];
         $payments = ['c' => 'cash', 'k' => 'check'];
         $s = preg_grep("/^" . strtolower($q) . "/", $payments);
         if ($s) {
             $k = key($s);
             array_push($arr, ['table' => 'payment', 'item' => ucwords($s[$k]), 'id' => strtolower($k)]);
         }
     }
     //return $arr;
     if ($request->ajax()) {
         return $arr;
     } else {
         return abort('404');
     }
 }
Beispiel #11
0
 public function edit($id)
 {
     $defect = Defect::where('id', '=', $id)->with('defectItems.product')->first();
     //        dd($defect);
     if ($defect->customer_type == 1) {
         $customers = Employee::where('status', 1)->lists('name', 'id');
     } elseif ($defect->customer_type == 2) {
         $customers = Supplier::where('status', 1)->lists('company_name', 'id');
     } else {
         $customers = Customer::where('status', 1)->lists('name', 'id');
     }
     $salesOrder = new SalesOrder();
     if ($defect->is_replacement) {
         $salesOrder = SalesOrder::where('defect_id', '=', $defect->id)->with(['salesOrderItems', 'salesOrderItems.product', 'salesOrderItems.salesDelivery'])->first();
     }
     $personalAccount = PersonalAccount::where('person_type', '=', $defect->customer_type)->where('person_id', '=', $defect->customer_id)->first();
     return view('sales.receiveDefect.edit')->with(compact('defect', 'customers', 'personalAccount', 'salesOrder'));
 }
 public function index()
 {
     $suppliers = Supplier::where('status', '=', 1)->lists('company_name', 'id');
     return view('reports.purchasesReport.index')->with(compact('suppliers'));
 }
 public function edit($id)
 {
     $customers = Customer::where('status', 1)->lists('name', 'id');
     $suppliers = Supplier::where('status', 1)->lists('company_name', 'id');
     $employees = Supplier::where('status', 1)->lists('name', 'id');
     $providers = Supplier::where('status', 1)->lists('name', 'id');
     $materials = Material::where('type', array_flip(Config::get('common.material_type'))['Discarded'])->lists('name', 'id');
     $discardedSales = DiscardedSales::with(['DiscardedSalesDetail' => function ($q) {
         $q->where('status', 1);
     }])->findOrFail($id);
     return view('discardedSales.edit', compact('discardedSales', 'customers', 'materials', 'suppliers', 'employees', 'providers'));
 }
Beispiel #14
0
 public function registercs(Request $request)
 {
     $c = new Coa();
     $c->id = $request->input('id');
     $c->code = $request->input('code');
     $name = explode("+", $request->input('name'));
     $c->name = $name[1];
     $c->description = $request->input('description');
     $c->increasetypeid = $request->input('increasetypeid');
     $c->taxrateid = $request->input('taxrateid');
     $c->coatypeid = $request->input('coatypeid');
     $c->userid = $request->input('userid');
     $c->save();
     $pid = $request->input('code');
     Supplier::where('code', $pid)->update(['coastatus' => 1]);
     //$sn=$request->input('name');
     //Supplier::where('name',$sn)->update(['coastatus' => 1]);
     return redirect('coa');
 }
Beispiel #15
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $suppliers = Supplier::where('status', 1)->lists('company_name', 'id');
     $materials = Material::where('status', 1)->lists('name', 'id');
     $purchase = Purchase::with('purchaseDetails')->findOrFail($id);
     return view('purchases.edit', compact('suppliers', 'materials', 'purchase'));
 }
Beispiel #16
0
 public function getSuppliers()
 {
     $suppliers = Supplier::where('status', 1)->lists('company_name', 'id');
     $dropdown = view('ajaxView.supplierDropDown')->with('suppliers', $suppliers)->render();
     return response()->json($dropdown);
 }