Exemple #1
0
 public function store(CAppUI $AppUI = null)
 {
     global $AppUI;
     global $helpdesk_available;
     $perms = $AppUI->acl();
     $errorMsgArray = $this->check();
     if (count($errorMsgArray) > 0) {
         return $errorMsgArray;
     }
     if ($helpdesk_available && $this->file_helpdesk_item != 0) {
         $this->addHelpDeskTaskLog();
     }
     if ($msg = parent::store()) {
         return false;
     }
     addHistory('files', $this->file_id, 'store', $this->file_name, $this->file_id);
     return true;
 }
Exemple #2
0
 public function store()
 {
     $q = new DBQuery();
     if ($this->task_log_id) {
         $this->task_log_updated = $q->dbfnNow();
     } else {
         $this->task_log_created = $q->dbfnNow();
         $this->task_log_updated = $q->dbfnNow();
     }
     parent::store();
     $this->updateHoursWorked($this->task_log_task);
 }
Exemple #3
0
 public function store(CAppUI $AppUI)
 {
     $perms = $AppUI->acl();
     $stored = false;
     $errorMsgArray = $this->check();
     if (count($errorMsgArray) > 0) {
         return $errorMsgArray;
     }
     $this->company_id = (int) $this->company_id;
     /*
      * TODO: I don't like the duplication on each of these two branches, but I
      *   don't have a good idea on how to fix it at the moment...
      */
     if ($this->company_id && $perms->checkModuleItem('companies', 'edit', $this->company_id)) {
         if ($msg = parent::store()) {
             return $msg;
         }
         addHistory('companies', $this->company_id, 'update', $this->company_name, $this->company_id);
         $stored = true;
     }
     if (0 == $this->company_id && $perms->checkModuleItem('companies', 'add')) {
         if ($msg = parent::store()) {
             return $msg;
         }
         addHistory('companies', $this->company_id, 'add', $this->company_name, $this->company_id);
         $stored = true;
     }
     if ($stored) {
         $custom_fields = new CustomFields('companies', 'addedit', $this->company_id, 'edit');
         $custom_fields->bind($_POST);
         $sql = $custom_fields->store($this->company_id);
         // Store Custom Fields
     }
     return $stored;
 }
Exemple #4
0
 public function store(CAppUI $AppUI)
 {
     $perms = $AppUI->acl();
     $stored = false;
     $errorMsgArray = $this->check();
     if (count($errorMsgArray) > 0) {
         return $errorMsgArray;
     }
     if ($this->link_id && $perms->checkModuleItem('links', 'edit', $this->link_id)) {
         $q = new DBQuery();
         $this->link_date = $q->dbfnNow();
         if ($msg = parent::store()) {
             return $msg;
         }
         addHistory('links', $this->link_id, 'update', $this->link_name, $this->link_id);
         $stored = true;
     }
     if (0 == $this->link_id && $perms->checkModuleItem('links', 'add')) {
         $q = new DBQuery();
         $this->link_date = $q->dbfnNow();
         if ($msg = parent::store()) {
             return $msg;
         }
         addHistory('links', $this->link_id, 'add', $this->link_name, $this->link_id);
         $stored = true;
     }
     return $stored;
 }
Exemple #5
0
 public function store(CAppUI $AppUI = null)
 {
     global $AppUI;
     $errorMsgArray = $this->check();
     $this->contact_company = (int) $this->contact_company;
     $this->contact_department = (int) $this->contact_department;
     if (count($errorMsgArray) > 0) {
         return $errorMsgArray;
     }
     /*
      *  This  validates that any Contact saved will have a Display Name as
      * required by various dropdowns, etc throughout the system.  This is
      * mostly required when Contacts are generated via programatic methods and
      * not through the add/edit UI.
      */
     if (mb_strlen($this->contact_order_by) <= 1 || $this->contact_order_by == null) {
         //TODO: this should use the USERFORMAT to determine how display names are generated
         if ($this->contact_first_name == null && $this->contact_last_name == null) {
             $this->contact_order_by = $this->contact_email;
         } else {
             $this->contact_order_by = mb_trim($this->contact_first_name . ' ' . $this->contact_last_name);
         }
     }
     if ($this->contact_first_name == null) {
         $this->contact_first_name = '';
     }
     if ($this->contact_last_name == null) {
         $this->contact_last_name = '';
     }
     if ($this->contact_birthday == '') {
         $this->contact_birthday = null;
     }
     $q = new DBQuery();
     $this->contact_lastupdate = $q->dbfnNow();
     addHistory('contacts', $this->contact_id, 'store', $this->contact_first_name . ' ' . $this->contact_last_name, $this->contact_id);
     parent::store();
 }
Exemple #6
0
 public function store(CAppUI $AppUI = null)
 {
     global $AppUI;
     $perms = $AppUI->acl();
     $stored = false;
     $this->w2PTrimAll();
     $this->project_target_budget = str_replace(',', '', $this->project_target_budget);
     // ensure changes of state in checkboxes is captured
     $this->project_active = (int) $this->project_active;
     $this->project_private = (int) $this->project_private;
     $this->project_target_budget = $this->project_target_budget ? $this->project_target_budget : 0.0;
     $this->project_actual_budget = $this->project_actual_budget ? $this->project_actual_budget : 0.0;
     // Make sure project_short_name is the right size (issue for languages with encoded characters)
     if (mb_strlen($this->project_short_name) > 10) {
         $this->project_short_name = mb_substr($this->project_short_name, 0, 10);
     }
     if (empty($this->project_end_date)) {
         $this->project_end_date = null;
     }
     $errorMsgArray = $this->check();
     if (count($errorMsgArray) > 0) {
         return $errorMsgArray;
     }
     $this->project_id = (int) $this->project_id;
     // convert dates to SQL format first
     if ($this->project_start_date) {
         $date = new CDate($this->project_start_date);
         $this->project_start_date = $date->format(FMT_DATETIME_MYSQL);
     }
     if ($this->project_end_date) {
         $date = new CDate($this->project_end_date);
         $date->setTime(23, 59, 59);
         $this->project_end_date = $date->format(FMT_DATETIME_MYSQL);
     }
     if ($this->project_actual_end_date) {
         $date = new CDate($this->project_actual_end_date);
         $this->project_actual_end_date = $date->format(FMT_DATETIME_MYSQL);
     }
     // let's check if there are some assigned departments to project
     if ('' != $this->project_actual_end_date) {
         $obj->project_departments = implode(',', w2PgetParam($_POST, 'dept_ids', array()));
     }
     // check project parents and reset them to self if they do not exist
     if (!$this->project_parent) {
         $this->project_parent = $this->project_id;
         $this->project_original_parent = $this->project_id;
     } else {
         $parent_project = new CProject();
         $parent_project->load($this->project_parent);
         $this->project_original_parent = $parent_project->project_original_parent;
     }
     if (!$this->project_original_parent) {
         $this->project_original_parent = $this->project_id;
     }
     /*
      * TODO: I don't like the duplication on each of these two branches, but I
      *   don't have a good idea on how to fix it at the moment...
      */
     if ($this->project_id && $perms->checkModuleItem('projects', 'edit', $this->company_id)) {
         $q = new DBQuery();
         $this->project_updated = $q->dbfnNow();
         if ($msg = parent::store()) {
             return $msg;
         }
         addHistory('projects', $this->project_id, 'update', $this->project_name, $this->project_id);
         $stored = true;
     }
     if (0 == $this->project_id && $perms->checkModuleItem('projects', 'add')) {
         $q = new DBQuery();
         $this->project_updated = $q->dbfnNow();
         $this->project_created = $q->dbfnNow();
         if ($msg = parent::store()) {
             return $msg;
         }
         if (0 == $this->project_parent || 0 == $this->project_original_parent) {
             $this->project_parent = $this->project_id;
             $this->project_original_parent = $this->project_id;
             if ($msg = parent::store()) {
                 return $msg;
             }
         }
         addHistory('projects', $this->project_id, 'add', $this->project_name, $this->project_id);
         $stored = true;
     }
     //split out related departments and store them seperatly.
     $q = new DBQuery();
     $q->setDelete('project_departments');
     $q->addWhere('project_id=' . (int) $this->project_id);
     $q->exec();
     $q->clear();
     if ($this->project_departments) {
         $departments = explode(',', $this->project_departments);
         foreach ($departments as $department) {
             $q->addTable('project_departments');
             $q->addInsert('project_id', $this->project_id);
             $q->addInsert('department_id', $department);
             $q->exec();
             $q->clear();
         }
     }
     //split out related contacts and store them seperatly.
     $q->setDelete('project_contacts');
     $q->addWhere('project_id=' . (int) $this->project_id);
     $q->exec();
     $q->clear();
     if ($this->project_contacts) {
         $contacts = explode(',', $this->project_contacts);
         foreach ($contacts as $contact) {
             if ($contact) {
                 $q->addTable('project_contacts');
                 $q->addInsert('project_id', $this->project_id);
                 $q->addInsert('contact_id', $contact);
                 $q->exec();
                 $q->clear();
             }
         }
     }
     if ($stored) {
         $custom_fields = new CustomFields('projects', 'addedit', $this->project_id, 'edit');
         $custom_fields->bind($_POST);
         $sql = $custom_fields->store($this->project_id);
         // Store Custom Fields
     }
     return $stored;
 }