Пример #1
0
 public function showCustomRecord($parameters)
 {
     // types
     $parameters['types'] = array_map(function ($object) {
         $object->name = trans_choice($object->name, 1);
         return $object;
     }, config('projects.types'));
     // projects
     $parameters['projects'] = Project::builder()->get();
     return $parameters;
 }
Пример #2
0
 public function updateCustomRecord($parameters)
 {
     Project::where('id_090', $parameters['id'])->update(['customer_id_090' => $this->request->input('customerId'), 'customer_name_090' => $this->request->input('customerName'), 'name_090' => $this->request->input('name'), 'description_090' => $this->request->has('description') ? $this->request->input('description') : null, 'estimated_hours_090' => $this->request->has('estimatedHours') ? $this->request->input('estimatedHours') : 0, 'total_hours_090' => (double) $this->request->input('estimatedHours') - (double) $this->request->input('consumedHours'), 'price_090' => $this->request->has('price') ? $this->request->input('price') : null, 'init_date_090' => $this->request->has('initDate') ? \DateTime::createFromFormat(config('pulsar.datePattern'), $this->request->input('initDate'))->getTimestamp() : null, 'init_date_text_090' => $this->request->has('initDate') ? $this->request->input('initDate') : null, 'estimated_end_date_090' => $this->request->has('estimatedEndDate') ? \DateTime::createFromFormat(config('pulsar.datePattern'), $this->request->input('estimatedEndDate'))->getTimestamp() : null, 'estimated_end_date_text_090' => $this->request->has('estimatedEndDate') ? $this->request->input('estimatedEndDate') : null, 'end_date_090' => $this->request->has('endDate') ? \DateTime::createFromFormat(config('pulsar.datePattern'), $this->request->input('endDate'))->getTimestamp() : null, 'end_date_text_090' => $this->request->has('endDate') ? $this->request->input('endDate') : null, 'invoiced_090' => $this->request->has('invoiced')]);
     // start create check and create invoiced
     $project = Project::builder()->find($parameters['id']);
     // create invoiced from project
     if ($this->request->has('endDate') && !$project->invoiced_090) {
         Invoiced::create(['date_094' => date('U'), 'date_text_094' => date(config('pulsar.datePattern')), 'customer_id_094' => $this->request->input('customerId'), 'customer_name_094' => $this->request->input('customerName'), 'type_id_094' => 1, 'project_id_094' => $parameters['id'], 'history_id_094' => null, 'price_094' => $this->request->has('price') ? $this->request->input('price') : 0]);
         Project::where('id_090', $parameters['id'])->update(['invoiced_090' => true]);
     }
 }
Пример #3
0
 public function updateCustomRecord($parameters)
 {
     if ($this->request->has('projectId')) {
         $project = Project::builder()->find($this->request->input('projectId'));
         $customerId = $project->customer_id_090;
         $customerName = $project->customer_name_090;
     } else {
         $customerId = $this->request->input('customerId');
         $customerName = $this->request->input('customerName');
     }
     // check that has hours if endDate exist
     if ($this->request->has('endDate')) {
         $validation = History::validate(['hours' => $this->request->input('hours')], ['hoursRule' => true]);
         if ($validation->fails()) {
             return redirect()->route('edit' . ucfirst($this->routeSuffix), ['id' => $parameters['id'], 'offset' => $parameters['offset']])->withErrors($validation);
         }
     }
     // TODO, contemplar cuando se cambie las horas o de projecto, se recalcule las horas del proyecto
     // 1 - project
     //        if($this->request->input('type') == 1)
     //        {
     //            $history = History::builder()->find($parameters['id']);
     //            if($history->hours_093 != $this->request->input('hours'))
     //            {
     //                $newHours = $history->hours_093 - $this->request->input('hours');
     //            }
     //        }
     History::where('id_093', $parameters['id'])->update(['user_id_093' => $this->request->input('userId'), 'user_name_093' => $this->request->input('userName'), 'title_093' => $this->request->input('title'), 'description_093' => $this->request->has('description') ? $this->request->input('description') : null, 'type_id_093' => $this->request->input('type'), 'project_id_093' => $this->request->has('projectId') ? $this->request->input('projectId') : null, 'customer_id_093' => $customerId, 'customer_name_093' => $customerName, 'hours_093' => $this->request->has('hours') ? $this->request->input('hours') : null, 'price_093' => $this->request->has('price') ? $this->request->input('price') : null, 'request_date_093' => $this->request->has('requestDate') ? \DateTime::createFromFormat(config('pulsar.datePattern'), $this->request->input('requestDate'))->getTimestamp() : null, 'request_date_text_093' => $this->request->has('requestDate') ? $this->request->input('requestDate') : null, 'end_date_093' => $this->request->has('endDate') ? \DateTime::createFromFormat(config('pulsar.datePattern'), $this->request->input('endDate'))->getTimestamp() : null, 'end_date_text_093' => $this->request->has('endDate') ? $this->request->input('endDate') : null]);
 }
Пример #4
0
 private function endTodo($todo)
 {
     // if has enDate, so user has finished tour todo_
     if ($todo->finished_091) {
         // 1 - project
         if ($todo->type_id_091 == 1) {
             // updates hour projects
             $project = Project::builder()->find($todo->project_id_091);
             Project::where('id_090', $todo->project_id_091)->update(['consumed_hours_090' => $project->consumed_hours_090 + $todo->hours_091, 'total_hours_090' => $project->total_hours_090 - $todo->hours_091]);
             History::create(['user_id_093' => $todo->user_id_091, 'user_name_093' => $todo->user_name_091, 'type_id_093' => $todo->type_id_091, 'project_id_093' => $todo->project_id_091, 'customer_id_093' => $todo->customer_id_091, 'customer_name_093' => $todo->customer_name_091, 'title_093' => $todo->title_091, 'description_093' => $todo->description_091, 'price_093' => $todo->price_091, 'request_date_093' => $todo->request_date_091, 'request_date_text_093' => $todo->request_date_text_091, 'end_date_093' => $todo->end_date_091, 'end_date_text_093' => $todo->end_date_text_091, 'hours_093' => $todo->hours_091]);
             // delete todo_, after register history
             Todo::destroy($todo->id_091);
         } elseif ($todo->type_id_091 == 2) {
             $billing = Billing::create(['todo_id_092' => $todo->id_091, 'user_id_092' => $todo->user_id_091, 'user_name_092' => $todo->user_name_091, 'customer_id_092' => $todo->customer_id_091, 'customer_name_092' => $todo->customer_name_091, 'title_092' => $todo->title_091, 'description_092' => $todo->description_091, 'request_date_092' => $todo->request_date_091, 'request_date_text_092' => $todo->request_date_text_091, 'end_date_092' => $todo->end_date_091, 'end_date_text_092' => $todo->end_date_text_091, 'hours_092' => $todo->hours_091, 'price_092' => $todo->price_091]);
             // envío de notificación
             $notificationsAccount = Preference::getValue('projectsNotificationsAccount', 6);
             $emailAccount = EmailAccount::find($notificationsAccount->value_018);
             if ($emailAccount == null) {
                 return null;
             }
             config(['mail.host' => $emailAccount->outgoing_server_013]);
             config(['mail.port' => $emailAccount->outgoing_port_013]);
             config(['mail.from' => ['address' => $emailAccount->email_013, 'name' => $emailAccount->name_013]]);
             config(['mail.encryption' => $emailAccount->outgoing_secure_013 == 'null' ? null : $emailAccount->outgoing_secure_013]);
             config(['mail.username' => $emailAccount->outgoing_user_013]);
             config(['mail.password' => Crypt::decrypt($emailAccount->outgoing_pass_013)]);
             $users = User::builder()->where('profile_id_010', (int) Preference::getValue('projectsBillingProfile', 6)->value_018)->where('access_010', true)->get();
             $nameTo = '';
             foreach ($users as $key => $user) {
                 $nameTo .= $user->name_010 . ' ' . $user->surname_010;
                 if ($key < count($users) - 1) {
                     $nameTo .= ', ';
                 }
             }
             $dataMessage = ['nameTo' => $nameTo, 'users' => $users, 'subject' => 'Notificación de facturación de tarea', 'billing' => $billing];
             Mail::send('projects::emails.billing_notification', $dataMessage, function ($m) use($dataMessage) {
                 $m->subject($dataMessage['subject']);
                 foreach ($dataMessage['users'] as $user) {
                     $m->to($user->email_010, $user->name_010 . ' ' . $user->surname_010);
                 }
             });
         }
     }
 }