Exemple #1
0
 /**
  * function to get the field information for a list view (list,popup,related)
  * gets the object name with the module and the list type and then generates the 
  * persistant object for the module and returns the fields information.
  * @param string $module
  * @param integer $module_id
  * @param string $list_type
  * @return array with the field information
  */
 public function get_listview_field_info($module, $module_id, $list_type, $custom_view_id = 0)
 {
     $object_name = $this->generate_list_view_object_name($module, $list_type);
     $do_list = new $module();
     $do_list->sessionPersistent($object_name, "logout.php", TTL);
     if ((int) $custom_view_id > 0) {
         $do_customview_fields = new CustomViewFields();
         $fields_info = $do_customview_fields->get_custom_view_fields_information($custom_view_id);
     } else {
         // fall back to the module's member property list view field information
         $do_crm_fields = new CRMFields();
         $fields_info = $do_crm_fields->get_specific_fields_information($_SESSION[$object_name]->list_view_fields, $module_id, true);
     }
     $_SESSION[$object_name]->list_view_field_information = $fields_info;
     return $fields_info;
 }
 /**
  * function to edit custom view
  * @param object $evctl
  * @return void
  */
 public function eventEditRecord(EventControler $evctl)
 {
     $do_edit = true;
     $error_message = '';
     if ((int) $evctl->sqrecord == 0) {
         $error_message = _('Missing record id');
         $do_edit = false;
     } elseif ((int) $evctl->target_module_id == 0) {
         $error_message = _('Missing target module for custom view !');
         $do_edit = false;
     } elseif (trim($evctl->cvname) == '') {
         $error_message = _('Please add a custom view name before saving !');
         $do_edit = false;
     } elseif ((int) $evctl->sqrecord > 0) {
         $this->getId($evctl->sqrecord);
         if ($this->getNumRows() > 0) {
             if ($this->iduser != $_SESSION["do_user"]->iduser) {
                 $error_message = _('You do not have permission to edit the record !');
                 $do_edit = false;
             }
             if ($this->is_editable == 0) {
                 $error_message = _('You do not have permission to edit the record !');
                 $do_edit = false;
             }
             if ($this->deleted == 1) {
                 $error_message = _('You do not have permission to edit the record !');
                 $do_edit = false;
             }
         } else {
             $error_message = _('Custom view not found !');
             $do_edit = false;
         }
     }
     if (true === $do_edit) {
         $idcustom_view = (int) $evctl->sqrecord;
         $this->getId($idcustom_view);
         $is_public = $this->is_public;
         $is_default = $evctl->is_default == 'on' ? 1 : 0;
         if ($_SESSION["do_user"]->is_admin == 1) {
             $is_public = $evctl->is_public == 'on' ? 1 : 0;
         }
         $qry = "\n\t\t\tupdate `" . $this->getTable() . "`\n\t\t\tset \n\t\t\t`name` = ? ,\n\t\t\t`is_default` = ? ,\n\t\t\t`is_public` = ? \n\t\t\twhere \n\t\t\t`idcustom_view` = ?\n\t\t\t";
         $this->query($qry, array($evctl->cvname, $is_default, $is_public, $evctl->sqrecord));
         //reset default custom view if is_default is set
         if ($evctl->is_default == 'on') {
             $this->reset_default_custom_view($idcustom_view, $evctl->target_module_id);
         }
         //update custom view fields
         $do_custom_view_fields = new CustomViewFields();
         $do_custom_view_fields->update_custom_view_fields($evctl->sqrecord, $evctl->cv_fields);
         //add custom view filter
         $do_custom_view_filter = new CustomViewFilter();
         $do_custom_view_filter->update_custom_view_date_filter($evctl->sqrecord, $evctl->cv_date_field, $evctl->cv_date_field_type, $evctl->cv_date_start, $evctl->cv_date_end);
         //update advanced filter
         $adv_filter_data = array("cv_adv_fields_1" => $evctl->cv_adv_fields_1, "cv_adv_fields_type_1" => $evctl->cv_adv_fields_type_1, "cv_adv_fields_val_1" => $_POST["cv_adv_fields_val_1"], "cv_adv_fields_2" => $evctl->cv_adv_fields_2, "cv_adv_fields_type_2" => $evctl->cv_adv_fields_type_2, "cv_adv_fields_val_2" => $_POST["cv_adv_fields_val_2"], "cv_adv_fields_3" => $evctl->cv_adv_fields_3, "cv_adv_fields_type_3" => $evctl->cv_adv_fields_type_3, "cv_adv_fields_val_3" => $_POST["cv_adv_fields_val_3"], "cv_adv_fields_4" => $evctl->cv_adv_fields_4, "cv_adv_fields_type_4" => $evctl->cv_adv_fields_type_4, "cv_adv_fields_val_4" => $_POST["cv_adv_fields_val_4"], "cv_adv_fields_5" => $evctl->cv_adv_fields_5, "cv_adv_fields_type_5" => $evctl->cv_adv_fields_type_5, "cv_adv_fields_val_5" => $_POST["cv_adv_fields_val_5"]);
         $do_custom_view_filter->update_custom_view_adv_filter($idcustom_view, $adv_filter_data);
         //redirect after adding the custom view
         $next_page = NavigationControl::getNavigationLink($_SESSION["do_module"]->modules_full_details[$evctl->target_module_id]["name"], "list", '', '&custom_view_id=' . $idcustom_view);
         $dis = new Display($next_page);
         $evctl->setDisplayNext($dis);
     } else {
         $_SESSION["do_crm_messages"]->set_message('error', $error_message);
         $next_page = NavigationControl::getNavigationLink("CustomView", "edit", $idcustom_view);
         $dis = new Display($next_page);
         $evctl->setDisplayNext($dis);
     }
 }
Exemple #3
0
            $do_edit = false;
        }
        if ($module_obj->is_editable == 0) {
            $do_edit = false;
        }
    } else {
        $do_edit = false;
    }
} else {
    $do_edit = false;
}
if ($do_edit === false) {
    echo '<div class="alert alert-error alert-block" style="height:100px;margin-top:100px;margin-left:200px;margin-right:200px;">';
    echo '<h4>';
    echo _('Access Denied ! ');
    echo '</h4>';
    echo _('You are not authorized to perform this operation.');
    echo '</div>';
} else {
    $do_crmfields = new CRMFields();
    $do_custom_view_fields = new CustomViewFields();
    $do_custom_view_filter = new CustomViewFilter();
    $cv_fields = $do_crmfields->get_fieldinfo_grouped_by_block($module_obj->idmodule, true);
    $date_filters = $do_crmfields->get_date_fields($module_obj->idmodule, true);
    $date_filter_options = ViewFilterUtils::get_date_filter_otions();
    $advanced_filter_options = ViewFilterUtils::get_advanced_filter_options();
    $saved_fields = $do_custom_view_fields->get_custom_view_fields($sqcrm_record_id);
    $saved_date_filter = $do_custom_view_filter->get_date_filter_information($sqcrm_record_id);
    $saved_advanced_filter = $do_custom_view_filter->get_saved_advanced_filter_information($sqcrm_record_id);
    require_once 'view/customview_edit_view.php';
}