/** * 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); } }