Exemplo n.º 1
0
 public function retrieve_contact()
 {
     $params = retrieve_uid_oid();
     //check: I need at least one of the 3 parameters uid,oid,client_id
     if (is_null($params) || count($params) == 0) {
         return false;
     }
     return $this->mdl_invoices->get_contact($params);
 }
Exemplo n.º 2
0
 function form()
 {
     $this->redir->set_last_index();
     $data = array();
     $this->_post_handler();
     if ($_POST) {
         //it's an update or a new task
         //is it a validated submit? (i.e. are all the rules respected?)
         if ($this->mdl_tasks->validate()) {
             if (empty($this->mcbsb->task->task_id)) {
                 //it's a new task
                 if ($this->mcbsb->task->create()) {
                     $this->mcbsb->system_messages->success = 'Task has been successfully created';
                 } else {
                     $this->mcbsb->system_messages->error = 'Task has not been created';
                 }
             } else {
                 //it's an update
                 if ($this->mcbsb->task->update()) {
                     $this->mcbsb->system_messages->success = 'The task has been successfully updated';
                 } else {
                     $this->mcbsb->system_messages->error = 'The task has not been updated';
                 }
             }
             redirect('tasks');
         } else {
             $this->mcbsb->system_messages->error = 'The task has been successfully created';
         }
     }
     if ($task_id = uri_assoc('task_id', 3)) {
         //it's an old task to be edit
         $this->mcbsb->task->task_id = $task_id;
         if ($this->mdl_tasks->get()) {
             //this populates $this->mcbsb->task with contact information
             //task and contact have been found.
             $data['task'] = $this->mcbsb->task;
         } else {
             $this->mcbsb->system_messages->error = 'The specified task can not be retrieved';
             redirect('tasks');
         }
         $modules = $this->mcbsb->get_enabled_modules();
         //TODO FIXME this is no good. Somehow it translates the modules names
         if (in_arrayi('activities', $modules['all']) || in_arrayi('attivitá', $modules['all'])) {
             //loads the Activity obj into the mcbsb obj
             $this->load->model('activities/mdl_activities', 'activities');
             $params = array('where' => array('task_id' => $this->mcbsb->task->task_id));
             if ($activities = $this->activities->getAll($params)) {
                 $data['activities'] = $activities;
                 $data['table'] = $this->plenty_parser->parse('table.tpl', $data, true, 'smarty', 'activities');
             }
         }
     } else {
         //it's a new task
         $values = retrieve_uid_oid();
         if (isset($values['client_id'])) {
             $this->mcbsb->task->client_id = $values['client_id'];
         }
         if (isset($values['client_id_key'])) {
             $this->mcbsb->task->client_id_key = $values['client_id_key'];
         }
         if (!$this->mdl_tasks->retrieve_contact_name($this->mcbsb->task)) {
             $this->mcbsb->system_messages->error = 'The contact related to the task can not be retrieved';
             redirect('contact');
         }
         $this->mcbsb->task->start_date = now();
         $data['task'] = $this->mcbsb->task;
     }
     $data['site_url'] = site_url($this->uri->uri_string());
     $data['actions_panel'] = $this->plenty_parser->parse('actions_panel.tpl', $data, true, 'smarty', 'tasks');
     $this->load->view('form', $data);
 }
Exemplo n.º 3
0
 public function retrieve_contact()
 {
     $params = retrieve_uid_oid();
     //check: I need at least one of the 3 parameters uid,oid,client_id
     if (is_null($params) || count($params) == 0) {
         return false;
     }
     //when the request is performed using client_id || uid || oid as input I get an object in return, not an array
     if (is_object($obj = $this->get($params))) {
         //$obj = $rest_return;
         $obj->prepareShow();
         return $obj;
     }
     return false;
 }