Esempio n. 1
0
 public function create()
 {
     $data['title'] = "Create Vpn";
     $data['company'] = Company::find($id);
     $data['company']->company_id = $data['company']->id;
     return view('equipment/create', $data);
 }
Esempio n. 2
0
 static function operatorsOnline($company_id)
 {
     $response = 0;
     $department_admin_ids = CompanyDepartmentAdmins::where('company_id', $company_id)->lists('user_id');
     $company = Company::find($company_id);
     $user = User::find($company->user_id);
     if ($user->is_online == 1) {
         return 1;
     } else {
         foreach ($department_admin_ids as $admin_id) {
             if ($response == 0) {
                 $user = User::find($admin_id);
                 if ($user->is_online == 1) {
                     return 1;
                 } else {
                     $department_admin = DepartmentAdmins::where('user_id', $admin_id)->first();
                     if (!empty($department_admin)) {
                         $operators_ids = OperatorsDepartment::where('department_id', $department_admin->department_id)->lists('user_id');
                         foreach ($operators_ids as $operators_id) {
                             if (sizeof(User::where('id', $operators_id)->get()) > 0) {
                                 $user = User::find($operators_id);
                                 if ($user->is_online == 1) {
                                     return 1;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $response;
 }
 public function getViewCompany($company_id)
 {
     $sql = "SELECT al.*, wrk.date_hired, wrk.date_finished, occ.title\n\t\t\t\tFROM alumni AS al\n\t\t\t\tINNER JOIN work_experience AS wrk\n\t\t\t\tON wrk.alumni_id = al.id\n\t\t\t\tINNER JOIN company AS com\n\t\t\t\tON com.id = wrk.company_id\n\t\t\t\tINNER JOIN occupation AS occ\n\t\t\t\tON occ.id = wrk.occupation_id\n\t\t\t\tWHERE com.id = ?";
     $company = Company::find($company_id);
     $employees = DB::select($sql, array($company_id));
     return View::make('admin.view_company')->with('company', $company)->with('employees', $employees);
 }
 public function all()
 {
     if (\KodeInfo\Utilities\Utils::isDepartmentAdmin(Auth::user()->id)) {
         $department_admin = DepartmentAdmins::where('user_id', Auth::user()->id)->first();
         $department = Department::where('id', $department_admin->department_id)->first();
         $company = Company::where('id', $department->company_id)->first();
         $messages = CannedMessages::where('company_id', $company->id)->where('department_id', $department->id)->orderBy('id', 'desc')->get();
     } elseif (\KodeInfo\Utilities\Utils::isOperator(Auth::user()->id)) {
         $department_admin = OperatorsDepartment::where('user_id', Auth::user()->id)->first();
         $department = Department::where('id', $department_admin->department_id)->first();
         $company = Company::where('id', $department->company_id)->first();
         $messages = CannedMessages::where('company_id', $company->id)->where('department_id', $department->id)->where('operator_id', Auth::user()->id)->orderBy('id', 'desc')->get();
     } else {
         $messages = CannedMessages::orderBy('id', 'desc')->get();
     }
     foreach ($messages as $message) {
         $operator = User::find($message->operator_id);
         $department = Department::find($message->department_id);
         $company = Company::find($message->company_id);
         $message->operator = $operator;
         $message->department = $department;
         $message->company = $company;
     }
     $this->data['messages'] = $messages;
     return View::make('canned_messages.all', $this->data);
 }
Esempio n. 5
0
 /**
  * Create a new User instance.
  *
  * @param  Object  $request
  * @return Response
  */
 public static function addUser()
 {
     $app = \Slim\Slim::getInstance();
     $request = (object) $app->request->post();
     //validate input
     $validata = $app->validata;
     $validator = $validata::key('email', $validata::email()->notEmpty())->key('first_name', $validata::stringType()->notEmpty())->key('last_name', $validata::stringType()->notEmpty())->key('password', $validata::stringType()->notEmpty())->key('company', $validata::intVal())->key('city', $validata::stringType()->notEmpty())->key('province', $validata::stringType()->notEmpty())->key('zip_code', $validata::stringType()->notEmpty())->key('address', $validata::stringType()->notEmpty());
     $errors = array();
     try {
         $validator->assert((array) $request);
     } catch (\InvalidArgumentException $e) {
         $errors = $e->findMessages(array('email' => '{{name}} must be a valid email', 'first_name' => '{{name}} is required', 'last_name' => '{{name}} is required', 'password' => 'Password is required', 'company' => 'Company is required', 'city' => 'City is required', 'province' => 'State/Province is required', 'address' => 'Address is required', 'zip_code' => 'Zipcode is required'));
     }
     if ($validator->validate((array) $request)) {
         if (!PasswordController::isValid($request->password, $request->email)) {
             $app->halt('400', json_encode("Password Formart Wrong"));
         }
         if (!Company::find($request->company)) {
             $app->halt('400', json_encode("Company does not exist"));
         }
         if (self::isExist($request->email)) {
             $app->response->setStatus(400);
             return json_encode("Email already taken");
         }
         $user = new User();
         //$user->name = $request->name;
         $user->email = $request->email;
         $user->password = PasswordController::encryptPassword($request->password);
         $user->first_name = $request->first_name;
         $user->last_name = $request->last_name;
         if (isset($request->phone)) {
             $user->phone = $request->phone;
         }
         $user->city = $request->city;
         $user->address = $request->address;
         $user->province = $request->province;
         $user->zip_code = $request->zip_code;
         $user->country = $request->country;
         $user->active = 0;
         $user->save();
         $app->response->setStatus(200);
         //send confirm email
         if ($user->id) {
             $user->companies()->attach($request->company);
             $link = WEBSITELINK . '/' . self::$active_api . openssl_encrypt($user->id, 'AES-256-CBC', self::$pass, 0, self::$iv);
             EmailController::newUserConfirmation($user->id, $request->password, $link);
         }
         return $user->id;
     } else {
         $app->response->setStatus(400);
         $return = [];
         foreach (array_values($errors) as $key => $error) {
             if ($error != "") {
                 array_push($return, array("code" => $key, "data" => $error));
             }
         }
         return json_encode($return);
     }
 }
Esempio n. 6
0
 public static function apiAll()
 {
     if (!Auth::user()->isAdmin()) {
         return [Company::find(Auth::user()["company_id"])];
     } else {
         return Company::all();
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $company = Company::find($id);
     $input = Input::all();
     $company->update($input);
     $company->save();
     return Redirect::to('admins/companies');
 }
Esempio n. 8
0
 public function dashboard($companies)
 {
     if (!Auth::check() or $companies != Auth::user()->company_id) {
         return Redirect::home();
     }
     $company = Company::find($companies);
     $products = $company->products;
     $products->load('orders');
     return View::make('companies.dashboard', compact('products'));
 }
Esempio n. 9
0
 public function update()
 {
     $company = User::find(Auth::user()->id)->company;
     $company = Company::find($company->id);
     $input = Input::all();
     $company->company_name = $input['company_name'];
     $company->company_address = $input['company_address'];
     $company->save();
     return Redirect::action('company.index');
 }
Esempio n. 10
0
 public function testSave()
 {
     $c = new Company();
     $c->name = 'Model Persister Company 2';
     $c->save();
     $this->assertNotNull($c->id);
     $c->name = 'Model Persister Company 2 updated';
     $c->save();
     $c2 = Company::find($c->id);
     $this->assertEquals($c2->name, 'Model Persister Company 2 updated');
 }
Esempio n. 11
0
 /**
  * Display the specified resource.
  * GET /orders/{id}
  *
  * @param  int $id
  * @return Response
  */
 public function show($company, $order)
 {
     if (is_numeric($order)) {
         $orders = Company::findOrFail($company)->orders->find($order);
         $offers = Offer::where('order_id', '=', $order)->where('provider_id', '=', Auth::user()->provider_id)->get();
         $company = Company::find($company);
         $interval = calculate_time_interval($orders->start_date, $orders->end_date);
         $dates = extract_dates($orders->start_date, $interval);
         $offer_dates = array_pluck($offers, 'date');
     }
     return View::make('orders.show', compact('offer_dates', 'offers', 'orders', 'company', 'interval', 'dates', 'start_at'));
 }
Esempio n. 12
0
 public function getList()
 {
     if (!empty($_REQUEST['uid'])) {
         $uid = (int) $_REQUEST['uid'];
         $where = array(array('uid', '=', $uid));
         $companyClass = new Company();
         $companyList = $companyClass->find($where);
         foreach ($companyList as $k => $company) {
             $companyList[$k] = $this->parse($company);
         }
         return $companyList;
     }
 }
Esempio n. 13
0
 public function initialize()
 {
     // Company
     $company = new Select('companyid', Company::find(), array('using' => array('id', 'name')));
     $company->setLabel('Empresa');
     $this->add($company);
     $number = new Text('name');
     $number->setLabel('Número de Torre');
     $number->addValidators(array(new PresenceOf(array('message' => 'Debe ingresar un numero de torre'))));
     $this->add($number);
     //añadimos un botón de tipo submit
     $submit = $this->add(new Submit('save', array('class' => 'btn btn-success')));
 }
 public function sendInvoice($invoice_id, $company_id)
 {
     $contact = Company::find((int) $company_id);
     if ($contact) {
         $put_url = '/sales_invoices/' . $invoice_id . '/send_invoice.json';
         $put_data = '{email:' . $contact->email . '}';
         try {
             $this->patchRequest($put_url, $put_data);
         } catch (Exception $e) {
             error_log($e->getMessage());
             die;
         }
     }
 }
Esempio n. 15
0
 public function testFind()
 {
     $cq = EQM::queryByPrimary(Company::class, 2);
     $cm = Company::find(2);
     $this->assertEquals($cq->id, $cm->id);
     $this->assertEquals($cq->name, $cm->name);
     $pq = EQM::queryByPrimary(Project::class, '2_2_PROJECT');
     $pm = Project::find('2_2_PROJECT');
     $this->assertEquals($pq->id, $pm->id);
     $this->assertEquals($pq->name, $pm->name);
     $paq = EQM::queryByPrimary(ProjectActivity::class, ['id' => 100, 'projectId' => '2_2_PROJECT']);
     $pam = ProjectActivity::find(['id' => 100, 'projectId' => '2_2_PROJECT']);
     $this->assertEquals($paq->id, $pam->id);
     $this->assertEquals($paq->name, $pam->name);
 }
Esempio n. 16
0
 public function initialize()
 {
     // Company
     $company = new Select('companyid', Company::find(), array('using' => array('id', 'name')));
     $company->setLabel('Company');
     $this->add($company);
     $tower = new Select('towerid', array('0' => 'Select a tower'));
     $tower->setLabel('Tower');
     $this->add($tower);
     $name = new Text('name');
     $name->setLabel('Apartment Name');
     $name->addValidators(array(new PresenceOf(array('message' => 'You must enter an apartment name'))));
     $this->add($name);
     //añadimos un botón de tipo submit
     $submit = $this->add(new Submit('save', array('class' => 'btn btn-success')));
 }
 public function getCustomers($company_id)
 {
     $customer_ids = CompanyCustomers::where('company_id', $company_id)->lists('customer_id');
     $customers = [];
     if (sizeof($customer_ids) > 0) {
         $customers = User::whereIn('id', $customer_ids)->get();
     }
     foreach ($customers as $customer) {
         $company_id = CompanyCustomers::where("customer_id", $customer->id)->pluck('company_id');
         $customer->company = Company::find($company_id);
         $customer->all_ticket_count = Tickets::where('customer_id', $customer->id)->count();
         $customer->pending_ticket_count = Tickets::where('customer_id', $customer->id)->where('status', Tickets::TICKET_PENDING)->count();
         $customer->resolved_ticket_count = Tickets::where('customer_id', $customer->id)->where('status', Tickets::TICKET_RESOLVED)->count();
     }
     $this->data['customers'] = $customers;
     return View::make('companies.customers', $this->data);
 }
Esempio n. 18
0
 protected function saveModel($venue = false)
 {
     if (Input::get('id')) {
         $venue = Venue::find(Input::get('id'));
     }
     if (!$venue) {
         $venue = new Venue();
     }
     $venue->name = Input::get('name');
     $venue->indoor_or_outdoor = Input::get('indoor_or_outdoor');
     $venue->name_of_hall = Input::get('name_of_hall');
     $venue->capacity = Input::get('capacity');
     $venue->dimension_height = Input::get('dimension_height');
     $venue->dimension_width = Input::get('dimension_width');
     $venue->dimension_length = Input::get('dimension_length');
     $venue->rigging_capacity = Input::get('rigging_capacity');
     $venue->notes = Input::get('notes');
     $address = $venue->address()->first() ?: new Address();
     $country = Country::where('name', Input::get('country'))->first();
     $address->country()->associate($country);
     $address->address = Input::get('address_address');
     $address->postal_code = Input::get('address_postal_code');
     $address->city = Input::get('address_city');
     $address->state_province = Input::get('address_state_province');
     $address->phone = Input::get('address_phone');
     $address->fax = Input::get('address_fax');
     $address->email = Input::get('address_email');
     $address->website = Input::get('address_website');
     $address->save();
     $venue->address()->associate($address);
     $venue->save();
     $venue->save();
     if (Input::get('company_id')) {
         $venue->companies()->detach(Company::find(Input::get('company_id')));
         $venue->companies()->attach(Company::find(Input::get('company_id')));
     }
     if (Input::get('contact_id')) {
         $venue->contacts()->detach(Contact::find(Input::get('contact_id')));
         $venue->contacts()->attach(Contact::find(Input::get('contact_id')));
     }
     return $venue;
 }
Esempio n. 19
0
 protected function saveModel($company = false)
 {
     if (Input::get('id')) {
         $company = Company::find(Input::get('id'));
     }
     if (!$company) {
         $company = new Company();
     }
     $company->name = Input::get('name');
     $company->type = Input::get('type');
     $company->references = Input::get('references');
     $company->bank_details = Input::get('bank_details');
     $company->tax_number = Input::get('tax_number');
     $company->notes = Input::get('notes');
     $address = $company->address()->first() ?: new Address();
     $country = Country::where('id', Input::get('country'))->first();
     $address->country()->associate($country);
     $address->address = Input::get('address_address');
     $address->postal_code = Input::get('address_postal_code');
     $address->city = Input::get('address_city');
     $address->state_province = Input::get('address_state_province');
     $address->phone = Input::get('address_phone');
     $address->fax = Input::get('address_fax');
     $address->email = Input::get('address_email');
     $address->website = Input::get('address_website');
     $address->save();
     $company->address()->associate($address);
     $company->save();
     if (Input::get('venue_id')) {
         $company->venues()->detach(Venue::find(Input::get('venue_id')));
         $company->venues()->attach(Venue::find(Input::get('venue_id')));
     }
     if (Input::get('contact_id')) {
         $company->contacts()->detach(Contact::find(Input::get('contact_id')));
         $company->contacts()->attach(Contact::find(Input::get('contact_id')));
     }
     if (Input::get('event_id')) {
         $company->events()->detach(Events::find(Input::get('event_id')));
         $company->events()->attach(Events::find(Input::get('event_id')));
     }
     return $company;
 }
 /**
  * Searches for company
  */
 public function searchAction()
 {
     $numberPage = 1;
     if ($this->request->isPost()) {
         $query = Criteria::fromInput($this->di, "Company", $_POST);
         $this->persistent->parameters = $query->getParams();
     } else {
         $numberPage = $this->request->getQuery("page", "int");
     }
     $parameters = $this->persistent->parameters;
     if (!is_array($parameters)) {
         $parameters = array();
     }
     $parameters["order"] = "id";
     $company = Company::find($parameters);
     if (count($company) == 0) {
         $this->flash->notice("The search did not find any company");
         return $this->dispatcher->forward(array("controller" => "company", "action" => "index"));
     }
     $paginator = new Paginator(array("data" => $company, "limit" => 10, "page" => $numberPage));
     $this->view->page = $paginator->getPaginate();
 }
Esempio n. 21
0
 function update($id = FALSE, $getview = FALSE)
 {
     if ($_POST) {
         unset($_POST['send']);
         unset($_POST['_wysihtml5_mode']);
         unset($_POST['files']);
         $id = $_POST['id'];
         $view = FALSE;
         if (isset($_POST['view'])) {
             $view = $_POST['view'];
         }
         unset($_POST['view']);
         if ($_POST['status'] == "Paid") {
             $_POST['paid_date'] = date('Y-m-d', time());
         }
         $estimate = Invoice::find($id);
         $estimate->update_attributes($_POST);
         if (!$estimate) {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_save_estimate_error'));
         } else {
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_save_estimate_success'));
         }
         redirect('estimates/view/' . $id);
     } else {
         $this->view_data['estimate'] = Invoice::find($id);
         $this->view_data['projects'] = Project::all();
         $this->view_data['companies'] = Company::find('all', array('conditions' => array('inactive=?', '0')));
         if ($getview == "view") {
             $this->view_data['view'] = "true";
         }
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_edit_estimate');
         $this->view_data['form_action'] = 'estimates/update';
         $this->content_view = 'estimates/_estimate';
     }
 }
Esempio n. 22
0
 /**
  * Display the specified offer.
  *
  * @param  int $id
  * @return Response
  */
 public function show($companies, $orders)
 {
     $offers = Offer::where('order_id', '=', $orders)->where('provider_id', '=', Auth::user()->provider_id)->get();
     $company = Company::find($companies);
     return View::make('offers.show', compact('offers', 'company'));
 }
//$summaries = Summary::where('employee_id', $employeeId)->whereBetween('daydate', [$cutOffDateFrom, $cutOffDateTo])->get();
$summary = DB::table('employee_summary')->select(DB::raw('SUM(lates) as lates, SUM(undertime) as undertime, SUM(absent) as absent, SUM(paid_sick_leave) as paid_sick_leave, SUM(paid_vacation_leave) as paid_vacation_leave, SUM(leave_without_pay) as leave_without_pay, SUM(maternity_leave) as maternity_leave, SUM(paternity_leave) as paternity_leave,
                      SUM(regular) as regular, SUM(regular_overtime) as regular_overtime, SUM(regular_overtime_night_diff) as regular_overtime_night_diff, SUM(regular_night_differential) as regular_night_differential, SUM(rest_day) as rest_day, SUM(rest_day_overtime) as rest_day_overtime, SUM(rest_day_overtime_night_diff) as rest_day_overtime_night_diff, SUM(rest_day_night_differential) as rest_day_night_differential,
                       SUM(rest_day_special_holiday) as rest_day_special_holiday, SUM(rest_day_special_holiday_overtime) as rest_day_special_holiday_overtime, SUM(rest_day_special_holiday_overtime_night_diff) as rest_day_special_holiday_overtime_night_diff, SUM(rest_day_special_holiday_night_diff) as rest_day_special_holiday_night_diff, SUM(rest_day_legal_holiday) as rest_day_legal_holiday, SUM(rest_day_legal_holiday_overtime) as rest_day_legal_holiday_overtime,
                       SUM(rest_day_legal_holiday_overtime_night_diff) as rest_day_legal_holiday_overtime_night_diff, SUM(rest_day_legal_holiday_night_diff) as rest_day_legal_holiday_night_diff, SUM(special_holiday) as special_holiday, SUM(special_holiday_overtime) as special_holiday_overtime, SUM(special_holiday_overtime_night_diff) as special_holiday_overtime_night_diff, SUM(special_holiday_night_diff) as special_holiday_night_diff, SUM(legal_holiday) as legal_holiday,
                       SUM(legal_holiday_overtime) as legal_holiday_overtime, SUM(legal_holiday_overtime_night_diff) as legal_holiday_overtime_night_diff, SUM(legal_holiday_night_diff) as legal_holiday_night_diff'))->where('employee_id', $employeeId)->whereBetween('daydate', [$cutOffDateFrom, $cutOffDateTo])->first();
//dd($summary);
$userGroups = DB::table('users_groups')->where('user_id', $userId)->first();
//$userGroups = DB::table('users_groups')->where('user_id', Auth::user()->id)->first();
if (!empty($userGroups)) {
    $groups = DB::table('groups')->where('id', (int) $userGroups->group_id)->first();
}
$currentUser = Sentry::getUser();
//$employeeId = Session::get('userEmployeeId');
//$employeeInfo[0]->id
$company = Company::find($employeeInfo[0]->company_id);
$department = Department::find($employeeInfo[0]->department_id);
$jobTitle = JobTitle::find($employeeInfo[0]->position_id);
$manager = '';
$manager = Employee::where('id', '=', $employeeInfo[0]->manager_id)->first();
if (!empty($manager)) {
    $managerFullname = $manager->firstname . ', ' . $manager->lastname;
} else {
    $managerFullname = '';
}
$employees = DB::table('employees')->where('manager_id', $employeeInfo[0]->id)->orWhere('supervisor_id', $employeeInfo[0]->id)->get();
$employeeArr[0] = '';
foreach ($employees as $employee) {
    $employeeArr[$employee->id] = $employee->firstname . ', ' . $employee->lastname;
}
//$getSchedule = DB::table('employee_schedule')->where('employee_id', $employee->id)->where('schedule_date', trim($currentDate))->get();
Esempio n. 24
0
//DELETE: EXISTING COMPANY
Route::get('/admin/company/delete/{id}', array('as' => 'adminDeleteCompany', 'uses' => function ($id) {
    $id = (int) $id;
    $employeeId = Session::get('userEmployeeId');
    $userId = Session::get('userId');
    $employee = new Employee();
    $employeeInfo = $employee->getEmployeeInfoById($employeeId);
    //return 'Update Company';
    return View::make('admin.companydelete', array('id' => $id, 'employeeInfo' => $employeeInfo));
    //return Redirect::route('updateCompany', array('id' => $id));
}));
//DELETE: EXISTING COMPANY
Route::post('/admin/company/delete/{id}', array('as' => 'adminProcessDeleteCompany', 'uses' => function ($id) {
    $data = Input::all();
    $id = (int) $id;
    $company = Company::find($id);
    if ($company->delete()) {
        $message = 'Deleted Successfully.';
        return Redirect::route('adminNewCompany')->with('message', $message);
    }
}));
//CREATE: NEW DEPARTMENT
Route::get('/admin/department/new', array('as' => 'adminNewDepartment', 'uses' => function () {
    //return 'Add Department';
    $employeeId = Session::get('userEmployeeId');
    $userId = Session::get('userId');
    $employee = new Employee();
    $employeeInfo = $employee->getEmployeeInfoById($employeeId);
    return View::make('admin.departmentnew', ['employeeInfo' => $employeeInfo]);
}));
//CREATE: NEW DEPARTMENT
Esempio n. 25
0
 public function company_valid($company_name)
 {
     $company = new Company();
     $company_exists = false;
     $data = $company->find("first", array("contain" => false, "field" => "Company.id", "joins" => array(array('table' => 'admins_companies', 'alias' => 'AdminsCompany', 'type' => 'LEFT', 'conditions' => "AdminsCompany.company_id=Company.id")), "conditions" => array("AdminsCompany.admin_id" => $this->admin_id, "Company.name" => $company_name)));
     if (!empty($data)) {
         $company_exists = true;
         $this->company_name = $company_name;
         $this->company_id = $data["Company"]["id"];
         $this->admin_id = $this->admin_id;
     } else {
         $this->sheet_errors[] = "Company " . $company_name . " is not assigned to you.";
     }
     return $company_exists;
 }
Esempio n. 26
0
 public function findCompanyNameByCode($comp_code = null)
 {
     //function to find all company name
     App::import("Model", "Company");
     $model = new Company();
     $query = $model->find('all', array('fields' => array('comp_name'), 'conditions' => array('Company.comp_code' => $comp_code)));
     if (empty($query)) {
         return 0;
     } else {
         return $query[0]['Company']['comp_name'];
     }
 }
Esempio n. 27
0
 function update($id = FALSE, $getview = FALSE)
 {
     if ($_POST) {
         unset($_POST['send']);
         unset($_POST['_wysihtml5_mode']);
         unset($_POST['files']);
         $config['upload_path'] = './files/media/';
         $config['encrypt_name'] = TRUE;
         $config['allowed_types'] = '*';
         $this->load->library('upload', $config);
         if ($this->upload->do_upload()) {
             $data = array('upload_data' => $this->upload->data());
             if ($_POST['attachment_description'] == "") {
                 $_POST['attachment_description'] = $data['upload_data']['orig_name'];
             }
             $_POST['attachment'] = $data['upload_data']['file_name'];
         }
         $id = $_POST['id'];
         $expense = Expense::find_by_id($id);
         $expense->update_attributes($_POST);
         if (!$expense) {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_save_expense_error'));
         } else {
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_save_expense_success'));
         }
         redirect('expenses');
     } else {
         $this->view_data['next_reference'] = Expense::last();
         $this->view_data['expense'] = Expense::find_by_id($id);
         $this->view_data['projects'] = Project::all();
         $this->view_data['core_settings'] = Setting::first();
         $this->view_data['companies'] = Company::find('all', array('conditions' => array('inactive=?', '0')));
         $this->theme_view = 'modal';
         $this->view_data['categories'] = Expense::find_by_sql("select category from expenses group by category");
         $this->view_data['title'] = $this->lang->line('application_create_expense');
         $this->view_data['form_action'] = 'expenses/update';
         $this->content_view = 'expenses/_expense';
     }
 }
Esempio n. 28
0
@extends('layouts.admin.default')

@section('content')

<?php 
$companyCount = Company::count();
$companies = Company::paginate(10);
$companyEdit = Company::find($id);
$message = Session::get('message');
?>

<div class="page-container">

        <div class="row" style="padding-bottom:20px;">

          <div class="col-md-2 clearfix">

            <aside class="sidebar">
              <nav class="sidebar-nav">
                <ul id="menu">
                  <li>
                    <a href="{{ url('/admin/dashboard') }}">
                      <span class="sidebar-nav-item-icon fa fa-tachometer fa-lg"></span>                      
                      <span class="sidebar-nav-item">Dashboard</span>                      
                    </a>
                    
                  </li>
                  <li>
                    <a href="#">
                      <span class="sidebar-nav-item-icon fa fa-users fa-lg"></span>                      
                      <span class="sidebar-nav-item">Employees</span>                      
Esempio n. 29
0
 function view($id = FALSE)
 {
     $this->view_data['submenu'] = array($this->lang->line('application_back') => 'clients');
     $this->view_data['company'] = Company::find($id);
     $this->view_data['invoices'] = Invoice::find('all', array('conditions' => array('estimate != ? AND company_id = ? AND estimate_status != ?', 1, $id, 'Declined')));
     $this->content_view = 'clients/view';
 }
 public function all()
 {
     $customer_ids = [];
     if (\KodeInfo\Utilities\Utils::isDepartmentAdmin(Auth::user()->id)) {
         $department_admin = DepartmentAdmins::where('user_id', Auth::user()->id)->first();
         $department = Department::where('id', $department_admin->department_id)->first();
         $customer_ids = CompanyCustomers::where("company_id", $department->company_id)->lists('customer_id');
     } elseif (\KodeInfo\Utilities\Utils::isOperator(Auth::user()->id)) {
         $department_admin = OperatorsDepartment::where('user_id', Auth::user()->id)->first();
         $department = Department::where('id', $department_admin->department_id)->first();
         $customer_ids = CompanyCustomers::where("company_id", $department->company_id)->lists('customer_id');
     } else {
         $customer_ids = CompanyCustomers::lists('customer_id');
     }
     if (sizeof($customer_ids) > 0) {
         $this->data["customers"] = User::whereIn("id", $customer_ids)->orderBy('id', 'desc')->get();
     } else {
         $this->data["customers"] = [];
     }
     foreach ($this->data["customers"] as $customer) {
         $company_id = CompanyCustomers::where("customer_id", $customer->id)->pluck('company_id');
         $customer->company = Company::find($company_id);
         $customer->all_ticket_count = Tickets::where('customer_id', $customer->id)->count();
         $customer->pending_ticket_count = Tickets::where('customer_id', $customer->id)->where('status', Tickets::TICKET_PENDING)->count();
         $customer->resolved_ticket_count = Tickets::where('customer_id', $customer->id)->where('status', Tickets::TICKET_RESOLVED)->count();
     }
     return View::make('customers.all', $this->data);
 }