Example #1
0
 function init()
 {
     parent::init();
     $employee_id = $this->app->stickyGET('contact_id');
     $project_id = $this->app->stickyGET('project_id');
     $on_date = $this->app->stickyGET('on_date');
     $model_employee = $this->add('xepan\\projects\\Model_Employee');
     $model_project = $this->add('xepan\\projects\\Model_Project');
     $model_timesheet = $this->add('xepan\\projects\\Model_Timesheet');
     $form = $this->add('Form', null, 'form');
     $emp_field = $form->addField('dropdown', 'employee')->setEmptyText('All');
     $emp_field->setModel($model_employee);
     $emp_field->set($this->api->stickyGET('contact_id'));
     $form->addField('dropdown', 'project')->setEmptyText('All')->setModel($model_project);
     $form->addField('DatePicker', 'on_date');
     $form->addSubmit('Check');
     if ($employee_id) {
         $model_timesheet->addCondition('employee_id', $employee_id);
     }
     if ($project_id) {
         $model_timesheet->addCondition('project_id', $project_id);
     }
     if ($on_date) {
         $model_timesheet->addCondition('start_time', '>', $on_date);
     }
     $grid = $this->add('xepan\\hr\\Grid', ['no_records_message' => 'No task found'], 'task', ['view\\task_timeline']);
     $grid->setModel($model_timesheet, ['task', 'duration']);
     if ($form->isSubmitted()) {
         return $grid->js()->reload(['project_id' => $form['project'], 'on_data' => $form['on_date'] ?: 0, 'employee_id' => $form['employee']])->execute();
     }
 }
Example #2
0
 function init()
 {
     parent::init();
     $project_id = $this->app->stickyGET('project_id');
     $model_project = $this->add('xepan\\projects\\Model_Project');
     $top_view = $this->add('xepan\\projects\\View_TopView', null, 'topview');
     $top_view->setModel($model_project)->load($project_id);
     $this->add('xepan\\projects\\View_Conversation', null, 'leftview');
 }
Example #3
0
 function render()
 {
     $project_id = $this->app->stickyGET('project_id');
     $model_task = $this->add('xepan\\projects\\Model_Task')->addCondition('project_id', $project_id)->addCondition('status', 'Pending')->addCondition('employee_id', $this->app->employee->id);
     $rows = [];
     foreach ($model_task as $task) {
         $rows[$task->id] = [];
         $rows[$task->id]['title'] = $task['task_name'];
         $rows[$task->id]['start'] = $task['created_at'] ?: '1970-01-01';
         $rows[$task->id]['end'] = $task['deadline'];
     }
     $task = array_values($rows);
     $this->js(true)->_load('fullcalendar.min')->_load('xepan-taskscheduler');
     $this->js(true)->_selector('#calendar')->univ()->taskDate($task);
     parent::render();
 }
Example #4
0
 function init()
 {
     parent::init();
     $project_id = $this->app->stickyGET('project_id');
     $model_project = $this->add('xepan\\projects\\Model_Formatted_Project');
     if ($project_id) {
         $model_project->load($project_id);
     }
     // $top_view = $this->add('xepan\projects\View_TopView',null,'topview');
     // $top_view->setModel($model_project,['name']);
     $model_employee = $this->add('xepan\\projects\\Model_Employee');
     $model_employee->addCondition('status', 'Active');
     $model_employee->setOrder('pending_tasks_count', 'desc');
     $model_employee->getElement('pending_tasks_count')->destroy();
     $model_employee->addExpression('pending_tasks_count')->set(function ($m, $q) use($project_id) {
         return $m->refSQL('xepan\\projects\\Task')->addCondition('status', 'Pending')->addCondition('project_id', $project_id)->count();
     });
     $project_detail_grid = $this->add('xepan\\hr\\Grid', null, 'grid', ['view\\status']);
     $project_detail_grid->add('xepan\\base\\Controller_Avatar', ['options' => ['size' => 40, 'border' => ['width' => 0]], 'name_field' => 'name', 'default_value' => '']);
     $project_detail_grid->addPaginator(50);
     $project_detail_grid->addQuickSearch(['name']);
     $project_detail_grid->setModel($model_employee, ['name', 'running_task', 'project', 'pending_tasks_count', 'running_task_since']);
     $project_detail_grid->js('click')->_selector('.do-view-project-live')->univ()->frameURL('Employee Project Status', [$this->api->url('xepan_projects_dailyanalysis'), 'contact_id' => $this->js()->_selectorThis()->closest('[data-id]')->data('id')]);
 }
Example #5
0
 function render()
 {
     $this->js(true)->_load('gantt\\ganttUtilities')->_load('gantt\\ganttTask')->_load('gantt\\ganttDrawerSVG')->_load('gantt\\ganttGridEditor')->_load('gantt\\ganttMaster')->_load('gantt\\ganttTask');
     $this->js(true)->_selector('#calendar')->GanttMaster();
     parent::render();
 }
Example #6
0
 function init()
 {
     parent::init();
     $this->start_date = $start_date = $_GET['start_date'] ?: date("Y-m-d", strtotime('-29 days', strtotime($this->app->today)));
     $this->end_date = $end_date = $_GET['end_date'] ?: $this->app->today;
     // // HEADER FORM
     $form = $this->add('Form', null, 'form_layout');
     $fld = $form->addField('DateRangePicker', 'period')->setStartDate($start_date)->setEndDate($end_date);
     $this->end_date = $this->app->nextDate($this->end_date);
     $form->addSubmit("Filter")->addClass('btn btn-primary');
     if ($form->isSubmitted()) {
         $form->app->redirect($this->app->url(null, ['start_date' => $fld->getStartDate() ?: 0, 'end_date' => $fld->getEndDate() ?: 0]));
     }
     // Communications by staff
     $model = $this->add('xepan\\hr\\Model_Employee');
     $model->addCondition('status', 'Active');
     $model->addExpression('pending_works')->set(function ($m, $q) {
         $task = $this->add('xepan\\projects\\Model_Task');
         $task->addCondition('assign_to_id', $q->getField('id'))->addCondition('created_by_id', '<>', $q->getField('id'))->addCondition('status', 'Pending')->addCondition($task->dsql()->andExpr()->where('created_at', '>=', $this->start_date)->where('created_at', '<=', $this->end_date));
         return $task->count();
     });
     $model->addExpression('please_receive')->set(function ($m, $q) {
         $task = $this->add('xepan\\projects\\Model_Task');
         $task->addCondition('assign_to_id', $q->getField('id'))->addCondition('created_by_id', '<>', $q->getField('id'))->addCondition('status', 'Assigned')->addCondition($task->dsql()->andExpr()->where('created_at', '>=', $this->start_date)->where('created_at', '<=', $this->end_date));
         return $task->count();
     });
     $model->addExpression('received_so_far')->set(function ($m, $q) {
         $task = $this->add('xepan\\projects\\Model_Task');
         $task->addCondition('assign_to_id', $q->getField('id'))->addCondition('created_by_id', '<>', $q->getField('id'))->addCondition($task->dsql()->andExpr()->where('created_at', '>=', $this->start_date)->where('created_at', '<=', $this->end_date));
         return $task->count();
     });
     $model->addExpression('total_tasks_assigned')->set(function ($m, $q) {
         $task = $this->add('xepan\\projects\\Model_Task');
         $task->addCondition('assign_to_id', '<>', $q->getField('id'))->addCondition('created_by_id', $q->getField('id'))->addCondition($task->dsql()->andExpr()->where('created_at', '>=', $this->start_date)->where('created_at', '<=', $this->end_date));
         return $task->count();
     });
     $model->addExpression('take_report_on_pending')->set(function ($m, $q) {
         $task = $this->add('xepan\\projects\\Model_Task');
         $task->addCondition('assign_to_id', '<>', $q->getField('id'))->addCondition('created_by_id', $q->getField('id'))->addCondition('status', ['Pending', 'Assigned'])->addCondition($task->dsql()->andExpr()->where('created_at', '>=', $this->start_date)->where('created_at', '<=', $this->end_date));
         return $task->count();
     });
     $model->addExpression('check_submitted')->set(function ($m, $q) {
         $task = $this->add('xepan\\projects\\Model_Task');
         $task->addCondition('assign_to_id', '<>', $q->getField('id'))->addCondition('created_by_id', $q->getField('id'))->addCondition('status', 'Submitted')->addCondition($task->dsql()->andExpr()->where('created_at', '>=', $this->start_date)->where('created_at', '<=', $this->end_date));
         return $task->count();
     });
     $this->add('xepan\\base\\View_Chart', null, 'Charts')->setType('bar')->setModel($model, 'name', ['pending_works', 'please_receive', 'received_so_far', 'total_tasks_assigned', 'take_report_on_pending', 'check_submitted'])->setGroup([['received_so_far', 'total_tasks_assigned'], ['pending_works', 'take_report_on_pending']])->setTitle('Staff Accountable System Use')->addClass('col-md-12');
     $project = $this->add('xepan\\projects\\Model_Project');
     $project->addExpression('Estimate')->set(function ($m, $q) {
         $task = $this->add('xepan\\projects\\Model_Task');
         $task->addCondition('project_id', $m->getElement('id'))->addCondition($task->dsql()->andExpr()->where('created_at', '>=', $this->start_date)->where('created_at', '<=', $this->end_date));
         return $task->_dsql()->del('fields')->field($q->expr('sum([0])', [$task->getElement('estimate_time')]));
     });
     $project->addExpression('Alloted')->set(function ($m, $q) {
         $task = $this->add('xepan\\projects\\Model_Task');
         $task->addCondition('project_id', $m->getElement('id'))->addCondition($task->dsql()->andExpr()->where('created_at', '>=', $this->start_date)->where('created_at', '<=', $this->end_date));
         $task->addExpression('diff_time')->set(function ($m, $q) {
             return $q->expr('TIMESTAMPDIFF([0],[1],[2])', ['HOUR', $q->getField('starting_date'), $q->getField('deadline')]);
         });
         return $task->_dsql()->del('fields')->field($q->expr('sum([0])', [$task->getElement('diff_time')]));
     });
     $project->addExpression('Consumed')->set(function ($m, $q) {
         $task = $this->add('xepan\\projects\\Model_Task');
         $task->addCondition('project_id', $m->getElement('id'));
         $task->addCondition('status', 'Completed')->addCondition($task->dsql()->andExpr()->where('created_at', '>=', $this->start_date)->where('created_at', '<=', $this->end_date));
         $task->addExpression('diff_time')->set(function ($m, $q) {
             return $q->expr('TIMESTAMPDIFF([0],[1],[2])', ['HOUR', $q->getField('starting_date'), $q->getField('updated_at')]);
         });
         return $task->_dsql()->del('fields')->field($q->expr('sum([0])', [$task->getElement('diff_time')]));
     });
     $project->addCondition([['Estimate', '>', 0], ['Alloted', '>', 0], ['Consumed', '>', 0]]);
     $this->add('xepan\\base\\View_Chart', null, 'Charts', null)->setType('bar')->setModel($project, 'name', ['Estimate', 'Alloted', 'Consumed'])->setGroup(['Estimate', 'Alloted', 'Consumed'])->setTitle('Project Hour Consumption')->addClass('col-md-8')->rotateAxis();
 }
Example #7
0
 function init()
 {
     parent::init();
     $this->js(true)->_load('timer.jquery');
     $from_date = $this->app->stickyGET('from_date');
     $to_date = $this->app->stickyGET('to_date');
     $task_priority = $this->app->stickyGET('priority');
     $task_id = $this->app->stickyGET('task_id');
     $search = $this->app->stickyGET('search');
     $project_id = $this->app->stickyGET('project_id');
     if (!$project_id) {
         return;
     }
     $model_project = $this->add('xepan\\projects\\Model_Formatted_Project')->load($project_id);
     /***************************************************************************
     			Adding views
     		***************************************************************************/
     $top_view = $this->add('xepan\\projects\\View_TopView', null, 'topview');
     $top_view->template->tryDel('my-timesheet-button-wrapper');
     $top_view->setModel($model_project);
     $task = $this->add('xepan\\projects\\Model_Task');
     $task->addCondition('project_id', $project_id);
     $employee = $this->add('xepan\\hr\\Model_Employee');
     $task_assigned_to_me = $this->add('xepan\\hr\\CRUD', ['allow_add' => null, 'grid_class' => 'xepan\\projects\\View_TaskList'], 'leftview');
     $task_assigned_to_me->grid->addClass('task-assigned-to-me');
     $task_assigned_to_me->js('reload')->reload();
     $task_assigned_by_me = $this->add('xepan\\hr\\CRUD', ['allow_add' => null, 'grid_class' => 'xepan\\projects\\View_TaskList'], 'middleview');
     $task_assigned_by_me->addClass('task-assigned-by-me');
     $task_assigned_by_me->js('reload')->reload();
     $task_waiting_for_approval = $this->add('xepan\\hr\\CRUD', ['allow_add' => null, 'grid_class' => 'xepan\\projects\\View_TaskList'], 'rightview');
     $task_waiting_for_approval->grid->addClass('task-waiting-for-approval');
     $task_waiting_for_approval->js('reload')->reload();
     $task_assigned_to_me->grid->template->trySet('task_view_title', 'Assigned To Me');
     $task_assigned_by_me->grid->template->trySet('task_view_title', 'Assigned By Me');
     $task_waiting_for_approval->grid->template->trySet('task_view_title', 'Waiting For Approval');
     $task_assigned_to_me->grid->addPaginator(25);
     $task_assigned_by_me->grid->addPaginator(25);
     $task_waiting_for_approval->grid->addPaginator(25);
     $filter_form = $this->add('Form', null, 'filter_form');
     $filter_form->setLayout('view\\form\\task-list-filter-form');
     $filter_form->addField('DatePicker', 'from_date')->set($this->app->now);
     $filter_form->addField('DatePicker', 'to_date')->set($this->app->now);
     $filter_form->addField('Dropdown', 'priority')->setvalueList(['25' => 'Low', '50' => 'Medium', '75' => 'High', '90' => 'Critical']);
     $filter_form->addSubmit('ApplyFilter')->addClass('btn btn-primary btn-block');
     $frm = $task_assigned_to_me->grid->addQuickSearch(['task_name']);
     if (!$frm->recall('task_status', false)) {
         $frm->memorize('task_status', ['Pending', 'Inprogress', 'Assigned']);
     }
     $status = $frm->addField('Dropdown', 'task_status');
     $status->setvalueList(['Pending' => 'Pending', 'Inprogress' => 'Inprogress', 'Assigned' => 'Assigned', 'Submitted' => 'Submitted', 'Completed' => 'Completed'])->setEmptyText('Select a status');
     $status->setAttr(['multiple' => 'multiple']);
     $frm1 = $task_assigned_by_me->grid->addQuickSearch(['task_name']);
     if (!$frm1->recall('task_status', false)) {
         $frm1->memorize('task_status', ['Pending', 'Inprogress', 'Assigned']);
     }
     $status1 = $frm1->addField('Dropdown', 'task_status');
     $status1->setvalueList(['Pending' => 'Pending', 'Inprogress' => 'Inprogress', 'Assigned' => 'Assigned', 'Submitted' => 'Submitted', 'Completed' => 'Completed'])->setEmptyText('Select a status');
     $status1->setAttr(['multiple' => 'multiple']);
     $frm2 = $task_waiting_for_approval->grid->addQuickSearch(['task_name']);
     $frm->addHook('applyFilter', function ($f, $m) {
         if (!is_array($f['task_status'])) {
             $f['task_status'] = explode(',', $f['task_status']);
         }
         if ($f['task_status'] and $m instanceof \xepan\projects\Model_Task) {
             $m->addCondition('status', $f['task_status']);
             $f->memorize('task_status', $f['task_status']);
         } else {
             $f->forget('task_status');
         }
     });
     $frm1->addHook('applyFilter', function ($f, $m) {
         if (!is_array($f['task_status'])) {
             $f['task_status'] = explode(',', $f['task_status']);
         }
         if ($f['task_status'] and $m instanceof \xepan\projects\Model_Task) {
             $m->addCondition('status', $f['task_status']);
             $f->memorize('task_status', $f['task_status']);
         } else {
             $f->forget('task_status');
         }
     });
     $status->js('change', $frm->js()->submit());
     $status1->js('change', $frm1->js()->submit());
     $task_assigned_to_me->template->trySet('task_view_title', 'Assigned To Me');
     $task_assigned_by_me->template->trySet('task_view_title', 'Assigned By Me');
     $task_waiting_for_approval->template->trySet('task_view_title', 'Submitted To Me');
     $task_assigned_to_me->add('xepan\\base\\Controller_Avatar', ['name_field' => 'created_by', 'image_field' => 'created_by_image', 'extra_classes' => 'profile-img center-block', 'options' => ['size' => 50, 'display' => 'block', 'margin' => 'auto'], 'float' => null, 'model' => $this->model]);
     $task_assigned_by_me->add('xepan\\base\\Controller_Avatar', ['name_field' => 'assign_to', 'image_field' => 'assigned_to_image', 'extra_classes' => 'profile-img center-block', 'options' => ['size' => 50, 'display' => 'block', 'margin' => 'auto'], 'float' => null, 'model' => $this->model]);
     $task_waiting_for_approval->add('xepan\\base\\Controller_Avatar', ['name_field' => 'assign_to', 'image_field' => 'assigned_to_image', 'extra_classes' => 'profile-img center-block', 'options' => ['size' => 50, 'display' => 'block', 'margin' => 'auto'], 'float' => null, 'model' => $this->model]);
     $status = 'Completed';
     $task_assigned_to_me_model = $this->add('xepan\\projects\\Model_Formatted_Task');
     $task_assigned_to_me_model->addCondition('project_id', $project_id)->addCondition($task_assigned_to_me_model->dsql()->orExpr()->where('assign_to_id', $this->app->employee->id)->where($task_assigned_to_me_model->dsql()->andExpr()->where('created_by_id', $this->app->employee->id)->where('assign_to_id', null)))->addCondition('type', 'Task');
     $task_assigned_to_me_model->setOrder(['updated_at', 'last_comment_time', 'priority']);
     $task_assigned_by_me_model = $this->add('xepan\\projects\\Model_Formatted_Task')->addCondition('project_id', $project_id)->addCondition('created_by_id', $this->app->employee->id)->addCondition('assign_to_id', '<>', $this->app->employee->id)->addCondition('assign_to_id', '<>', null)->addCondition('status', '<>', 'Submitted')->addCondition('type', 'Task');
     $task_assigned_by_me_model->setOrder(['updated_at', 'last_comment_time']);
     $task_waiting_for_approval_model = $this->add('xepan\\projects\\Model_Formatted_Task')->addCondition('status', 'Submitted')->addCondition('assign_to_id', '<>', null)->addCondition($this->app->db->dsql()->orExpr()->where('created_by_id', $this->app->employee->id)->where('assign_to_id', $this->app->employee->id))->addCondition('type', 'Task');
     $task_waiting_for_approval_model->setOrder(['updated_at', 'last_comment_time']);
     if ($from_date) {
         $task_assigned_to_me_model->addCondition('starting_date', '>=', $from_date);
         $task_assigned_by_me_model->addCondition('starting_date', '>=', $from_date);
     }
     if ($to_date) {
         $task_assigned_by_me_model->addCondition('deadline', '<=', $this->app->nextDate($to_date));
         $task_assigned_to_me_model->addCondition('deadline', '<=', $this->app->nextDate($to_date));
     }
     if ($task_priority) {
         $task_assigned_by_me_model->addCondition('priority', $task_priority);
         $task_assigned_to_me_model->addCondition('priority', $task_priority);
     }
     $task_assigned_to_me->setModel($task_assigned_to_me_model);
     $task_assigned_by_me->setModel($task_assigned_by_me_model);
     $task_waiting_for_approval->setModel($task_waiting_for_approval_model);
     if ($filter_form->isSubmitted()) {
         $js = [$task_assigned_by_me->js()->reload(['from_date' => $filter_form['from_date'], 'to_date' => $filter_form['to_date'], 'priority' => $filter_form['priority']]), $task_assigned_to_me->js()->reload(['from_date' => $filter_form['from_date'], 'to_date' => $filter_form['to_date'], 'priority' => $filter_form['priority']])];
         $filter_form->js(null, $js)->execute();
     }
     if ($task_id) {
         $task->load($task_id);
     }
     $task_assigned_to_me_url = $this->api->url(null, ['cut_object' => $task_assigned_to_me->name]);
     /***************************************************************************
     			Virtual page for TASK DETAIL
     		***************************************************************************/
     $self = $this;
     $self_url = $this->app->url(null, ['cut_object' => $this->name]);
     $vp = $this->add('VirtualPage');
     $vp->set(function ($p) {
         $task_id = $this->app->stickyGET('task_id') ?: 0;
         $project_id = $this->app->stickyGET('project_id');
         $p->add('xepan\\projects\\View_Detail', ['task_id' => $task_id, 'project_id' => $project_id]);
     });
     /***************************************************************************
     			Js to show task detail view etc.
     		***************************************************************************/
     $top_view->js('click', $this->js()->univ()->frameURL("ADD NEW TASK/Request", $this->api->url($vp->getURL())))->_selector('.add-task');
 }
Example #8
0
 function render()
 {
     $this->app->jui->addStaticInclude('jquery.easypiechart.min');
     parent::render();
 }