/**
  ** Function to plot graphs
  ***/
 public function index()
 {
     if (isset($_POST) && !empty($_POST['datepickerfrom']) && !empty($_POST['datepickerto'])) {
         $datefrom = $_POST['datepickerfrom'];
         $dateto = $_POST['datepickerto'];
     }
     $projectsArray = Project::all();
     /**Get all projects from databa se */
     $result_array = Report::all();
     if (!empty($result_array)) {
         foreach ($result_array as $key => $res) {
             $project[$key]['name'] = $res['name'];
             $projects[$key]['id'] = $res['id'];
         }
     } else {
         echo '<p class="error_msg">No data available in this range</p> <p>Please click <a href="?controller=pages&action=reportdata">Report</a> to select another range</p>';
         exit;
     }
     $date_range = $this->getDatesFromRange($datefrom, $dateto);
     $xaxis_data = json_encode($date_range);
     for ($rs = 0; $rs < count($project); $rs++) {
         foreach ($date_range as $dt) {
             $bugs[$rs] = Report::find($projects[$rs]['id'], $dt);
             $project[$rs]['data'][] = intval($bugs[$rs][$projects[$rs]['id']]['bugs']);
         }
     }
     $result_array = json_encode($project);
     require_once 'views/reports/index.php';
 }
Example #2
0
 public static function edit($id)
 {
     self::check_logged_in();
     $task = Task::find($id);
     $task->projectids = explode(",", $task->projectids);
     $projects = Project::all();
     View::make('task/edit.html', array('attributes' => $task, 'projects' => $projects));
 }
 public function getProjects()
 {
     $projects = Project::all();
     foreach ($projects as $project) {
         $project->rendered_html = $project->html();
     }
     return $projects;
 }
 function __construct()
 {
     parent::__construct();
     $this->view_data['core_settings'] = Setting::first();
     if ($this->input->cookie('language') != "") {
         $language = $this->input->cookie('language');
     } else {
         if (isset($this->view_data['language'])) {
             $language = $this->view_data['language'];
         } else {
             if (!empty($this->view_data['core_settings']->language)) {
                 $language = $this->view_data['core_settings']->language;
             } else {
                 $language = "english";
             }
         }
     }
     $this->lang->load('application', $language);
     $this->lang->load('messages', $language);
     $this->lang->load('event', $language);
     $this->user = $this->session->userdata('user_id') ? User::find_by_id($this->session->userdata('user_id')) : FALSE;
     $this->client = $this->session->userdata('client_id') ? Client::find_by_id($this->session->userdata('client_id')) : FALSE;
     if ($this->client) {
         $this->theme_view = 'application_client';
     }
     $this->view_data['datetime'] = date('Y-m-d H:i', time());
     $this->view_data['sticky'] = Project::all(array('conditions' => 'sticky = 1'));
     $this->view_data['quotations_new'] = Quote::find_by_sql("select count(id) as amount from quotations where status='New'");
     if ($this->user || $this->client) {
         $access = $this->user ? $this->user->access : $this->client->access;
         $access = explode(",", $access);
         if ($this->user) {
             $this->view_data['menu'] = Module::find('all', array('order' => 'sort asc', 'conditions' => array('id in (?) AND type = ?', $access, 'main')));
             $this->view_data['widgets'] = Module::find('all', array('conditions' => array('id in (?) AND type = ?', $access, 'widget')));
         } else {
             $this->view_data['menu'] = Module::find('all', array('order' => 'sort asc', 'conditions' => array('id in (?) AND type = ?', $access, 'client')));
         }
         if ($this->user) {
             $update = User::find($this->user->id);
         } else {
             $update = Client::find($this->client->id);
         }
         $update->last_active = time();
         $update->save();
         if ($this->user) {
             $this->view_data['user_online'] = User::all(array('conditions' => array('last_active+(30 * 60) > ? AND status = ?', time(), "active")));
             $this->view_data['client_online'] = Client::all(array('conditions' => array('last_active+(30 * 60) > ? AND inactive = ?', time(), "0")));
         }
         $email = $this->user ? 'u' . $this->user->id : 'c' . $this->client->id;
         $this->view_data['messages_new'] = Privatemessage::find_by_sql("select count(id) as amount from privatemessages where `status`='New' AND recipient = '" . $email . "'");
         $this->view_data['tickets_new'] = Ticket::find_by_sql("select count(id) as amount from tickets where `status`='New'");
     }
     /*$this->load->database();
     		$sql = "select * FROM templates WHERE type='notes'";
     		$query = $this->db->query($sql); */
     $this->view_data["note_templates"] = "";
     //$query->result();
 }
 public function edit()
 {
     if (!Auth::user()->is_superadmin) {
         App::abort(403, 'Unauthorized action.');
     }
     $id = intval(Input::get('id'));
     $user = null;
     if ($id) {
         $user = User::find($id);
     }
     $error = '';
     if (Request::isMethod('post')) {
         $username = trim(Input::get('username'));
         $password = trim(Input::get('password'));
         $is_superadmin = intval(Input::get('is_superadmin'));
         $project_ids = Input::get('project', array());
         if ($user) {
             if ($password) {
                 $user->password = Hash::make($password);
             }
         } else {
             if (!$username || !$password) {
                 $error = '信息不完整!';
             }
             if (User::where("username", $username)->count()) {
                 $error = '用户名不能和已有用户重复';
             }
         }
         if (!$error) {
             if (!$user) {
                 $user = new User();
                 $user->username = $username;
                 $user->password = Hash::make($password);
             }
             $user->is_superadmin = $is_superadmin;
             $user->save();
             //如果不是超级管理员,处理传过来的项目id数组
             if (!$user->is_superadmin) {
                 $owned_pj = $user->pj_ids();
                 foreach ($project_ids as $value) {
                     if (!in_array($value, $owned_pj)) {
                         $_tmp = new UserProjectRelation();
                         $_tmp->uid = $user->id;
                         $_tmp->prj_id = $value;
                         $_tmp->save();
                     } else {
                         unset($owned_pj[array_search($value, $owned_pj)]);
                     }
                 }
                 if (!empty($owned_pj)) {
                     UserProjectRelation::where('uid', $user->id)->whereIn('prj_id', $owned_pj)->delete();
                 }
             }
             return Redirect::to('/users/index');
         }
     }
     return View::make('users/edit', array('user' => $user, 'error' => $error, 'projects' => Project::all()));
 }
Example #6
0
 public function index()
 {
     $currProject = Auth::user()->curr_project_id;
     $currLocation = Auth::user()->location_id;
     $projects = Project::all();
     $locations = Location::all();
     $menu = 'setup';
     return View::make('setups/index', compact('projects', 'locations', 'currProject', 'currLocation', 'menu'));
 }
 public function index()
 {
     $projects = Project::all();
     if (count($projects)) {
         foreach ($projects as $project) {
             $project->image = $project->images()->first();
         }
         return Response::json($projects);
     } else {
         return Response::json(['alert' => 'Projects' . Messages::$notFound], 404);
     }
 }
Example #8
0
 /**
  * Handles GET requests for /dashboard
  *
  * @return view
  */
 public function getDashboard()
 {
     if ($this->user->hasAnyAccess(['manage'])) {
         $projects = Project::all();
     } else {
         if (!empty($projects = $this->setProjects())) {
             $projects = Project::whereIn('id', $projects)->orWhere('user_id', $this->user->id)->orderBy('id')->get();
         } else {
             $projects = Project::where('user_id', $this->user->id)->orderBy('id')->get();
         }
     }
     return View::make('layouts.dashboard')->with(['projects' => $projects]);
 }
Example #9
0
 function filter($condition)
 {
     switch ($condition) {
         case 'open':
             $options = array('conditions' => 'progress < 100');
             break;
         case 'closed':
             $options = array('conditions' => 'progress = 100');
             break;
     }
     $this->view_data['project'] = Project::all($options);
     $this->content_view = 'projects/all';
 }
Example #10
0
 public function showProject($id)
 {
     $project = Project::find($id);
     if ($id == 'random') {
         $projects = Project::all();
         $project = $projects[mt_rand(0, count($projects) - 1)];
     }
     if (!$project) {
         return Redirect::to('search')->with('error', 'Oops! It seems we can\'t find the page you are looking for. Try search instead.');
     }
     $geojson = 'pin-l-circle-stroked+1abc9c(' . $project->geo()->lng . ',' . $project->geo()->lat . ')/' . $project->geo()->lng . ',' . $project->geo()->lat . '),13';
     $map_image_link = 'https://api.tiles.mapbox.com/v4/codeforafrica.ji193j10/' . $geojson . '/520x293.png256?' . 'access_token=pk.eyJ1IjoiY29kZWZvcmFmcmljYSIsImEiOiJVLXZVVUtnIn0.JjVvqHKBGQTNpuDMJtZ8Qg';
     $data = compact('project', 'map_image_link', 'geojson');
     return view('home.project', $data);
 }
 function filter($condition)
 {
     switch ($condition) {
         case 'open':
             $options = array('conditions' => 'progress < 100');
             break;
         case 'closed':
             $options = array('conditions' => 'progress = 100');
             break;
     }
     $this->view_data['project'] = Project::all($options);
     $this->content_view = 'projects/all';
     $this->view_data['projects_assigned_to_me'] = ProjectHasWorker::find_by_sql('select count(distinct(projects.id)) AS "amount" FROM projects, project_has_workers WHERE projects.progress != "100" AND (projects.id = project_has_workers.project_id AND project_has_workers.user_id = "' . $this->user->id . '") ');
     $this->view_data['tasks_assigned_to_me'] = ProjectHasTask::count(array('conditions' => 'user_id = ' . $this->user->id . ' and status = "open"'));
     $now = time();
     $beginning_of_week = strtotime('last Monday', $now);
     // BEGINNING of the week
     $end_of_week = strtotime('next Sunday', $now) + 86400;
     // END of the last day of the week
     $this->view_data['projects_opened_this_week'] = Project::find_by_sql('select count(id) AS "amount", DATE_FORMAT(FROM_UNIXTIME(`datetime`), "%w") AS "date_day", DATE_FORMAT(FROM_UNIXTIME(`datetime`), "%Y-%m-%d") AS "date_formatted" from projects where datetime >= "' . $beginning_of_week . '" AND datetime <= "' . $end_of_week . '" ');
 }
Example #12
0
 public function savestatus()
 {
     $projects = Project::all();
     $pr_id = $_POST['project_list'];
     $dateofbug = $_POST['datepicker'];
     $bugs = $_POST['bugs'];
     $exst = Project::checkBugsbypro($pr_id, $dateofbug);
     if ($exst) {
         $update = Project::updateBugsbypro($bugs, $pr_id, $dateofbug);
         if ($update) {
             $this->redirecturl('pages', 'createstatus', 'true');
         } else {
             $this->redirecturl('pages', 'createstatus', 'false');
         }
     } else {
         $bugsave = Project::insertBugs($pr_id, $dateofbug, $bugs);
         if ($bugsave) {
             $this->redirecturl('pages', 'createstatus', 'true');
         }
     }
 }
 /**
  * Display a listing of the resource.
  * GET /projects
  *
  * @return Response
  */
 public function index()
 {
     $projects = Project::all();
     //return View::make('projects.index');
     $this->layout->content = View::make('projects.index', compact('projects'));
 }
Example #14
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';
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $projects = Project::all();
     return View::make('projects.index')->withProjects($projects);
 }
Example #16
0
 public function getAllProjects()
 {
     $projects = Project::all();
     return $projects;
 }
Example #17
0
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::get('/', 'HomeController@welcome');
Route::get('/ajax/get-projects', 'HomeController@getProjects');
Route::get('/ajax/get-offices', 'HomeController@getOffices');
Route::get('/ajax/get-customer-projects', 'HomeController@getCustomerProjects');
Route::get('/ajax/get-project-tweets/{hashtag}', 'HomeController@getProjectTweets');
Route::resource('/admin/projects', 'ProjectsController');
Route::resource('/admin/offices', 'OfficesController');
Route::resource('/admin/customers', 'CustomersController');
Route::get('/admin/about-us/edit-current', 'AboutUsController@editCurrent');
Route::resource('/admin/about-us', 'AboutUsController');
Route::get('/login', 'UsersController@showLogin');
Route::post('/login', 'UsersController@doLogin');
Route::get('/logout', 'UsersController@logout');
Route::get('/update-dates', function () {
    $projects = Project::all();
    foreach ($projects as $project) {
        $project->date_started = date('Y-m-d');
        $project->save();
    }
});
Example #18
0
 /**
  * [postModelData - handle posted data associated with a specific company]
  * @param  [Eloquent model] $model  [company model]
  * @return [json]                   [DT compatible object]
  */
 public function postModelData($model)
 {
     $Model = $this->modelName;
     // Build our Editor instance and process the data coming from _POST
     global $db;
     $data = Editor::inst($db, 'worklogs')->fields(Field::inst('worklogs.id'), Field::inst('worklogs.date'), Field::inst('worklogs.company_id'), Field::inst('worklogs.project_id'), Field::inst('projects.name'), Field::inst('worklogs.user_id'), Field::inst('users.username'), Field::inst('worklogs.minutes')->validator('Validate::notEmpty'), Field::inst('worklogs.description'), Field::inst('worklogs.comment'), Field::inst('worklogs.billable')->validator('Validate::boolean'), Field::inst('worklogs.processed')->validator('Validate::boolean'))->leftJoin('users', 'users.id', '=', 'worklogs.user_id')->leftJoin('projects', 'projects.id', '=', 'worklogs.project_id')->leftJoin('strippenkaarten', 'strippenkaarten.id', '=', 'worklogs.strippenkaarten_id')->process($_POST)->data();
     $data['projects'] = Project::all(['id as value', 'name as label']);
     $data['users'] = User::all(['id as value', 'username as label']);
     $data['strippenkaarten'] = Strippenkaart::where('expiry_date', '=', null)->get(['id as value', 'hours as label']);
     return Response::json($data);
 }
Example #19
0
 public function myprojects()
 {
     $view = $this->getActionView();
     if (RequestMethods::post('approve')) {
         $pro = Project::first(array('id = ?' => RequestMethods::post('id')));
         $pro->approve = 1;
         $pro->status = "approved";
         $pro->save();
     }
     if (isset($this->_user)) {
         $admin = User::first(array('id = ?' => $this->user->id, 'admin = ?' => 1));
         if (!empty($admin)) {
             $pro = Project::all();
             $view->set('admin', $admin)->set('pro', $pro);
         } else {
             $manager = User::first(array('id = ?' => $this->user->id, 'type = ?' => 'manager'));
             if (!empty($manager)) {
                 $pro = Project::all(array('managerid = ?' => $this->user->id));
                 $view->set('manager', $manager)->set('pro', $pro);
             } else {
                 $client = User::first(array('id = ?' => $this->user->id, 'type = ?' => 'client'));
                 $pro = Project::all(array('clientid = ?' => $this->user->id));
                 $view->set('client', $client)->set('pro', $pro);
             }
         }
     }
 }
Example #20
0
 public static function index()
 {
     self::check_logged_in();
     $projects = Project::all();
     View::make('project/index.html', array('projects' => $projects));
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     return View::make('projects.index')->with('projects', Project::all())->with('title', 'Projects');
 }
Example #22
0
 public function loadProjects()
 {
     $projects = Project::all();
     return $projects->toJson();
 }
Example #23
0
 public function index()
 {
     return View::make('project.index')->with('projects', Project::all());
 }
Example #24
0
Route::get('/', function () {
});
Route::get('/', function () {
    if (Sentry::check()) {
        $user = Sentry::getUser();
        $email = $user->email;
        $name = $user->agent_Name;
        $project = $user->project_ID;
        return View::make('home')->with('user', $email)->with('name', $name)->with('project', $project);
    }
    return View::make("login")->with("title", "Leave APP")->with('heading', 'LEAVE APP');
});
Route::get('/logout', function () {
    Sentry::logout();
    return View::make("login")->with("title", "Leave APP")->with('heading', 'LEAVE APP');
});
Route::post('/login', array('as' => 'user.login', 'uses' => 'UserController@user_login'));
Route::get('add', function () {
    return View::make('create');
});
Route::get('projects', function () {
    return Project::all();
});
Route::post('leave/delete', array('as' => 'leave.destroy', 'uses' => 'LeaveController@destroy'));
Route::get('agents', function () {
    $agents = DB::table('users')->join('Projects', 'users.project_ID', '=', 'Projects.Project_ID')->select('users.agent_ID', 'users.agent_Name', 'Projects.project_Name')->orderBy('Agent_Name', 'desc')->get();
    return Response::json($agents);
});
Route::get('leave', 'LeaveController@index');
Route::post('save', array('as' => 'leave.create', 'uses' => 'LeaveController@create'));
Route::post('agentSave', array('as' => 'agent.create', 'uses' => 'AgentController@create'));
Example #25
0
 public function index()
 {
     $projects = Project::all();
     $menu = 'project';
     return View::make('projects.index', compact('projects', 'menu'));
 }
 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';
     }
 }
Example #27
0
 /**
  * Display a listing of portfolios
  *
  * @return Response
  */
 public function adminIndex($project = NULL)
 {
     parent::show();
     $projects = Project::all();
     return View::make('projects.admin_index', compact('projects'));
 }