示例#1
0
 /**
  * function to export the list view data
  * @param string $module
  * @param integer $module_id
  * @param string $type
  * @param integer $view_id
  * @see self::export_data()
  */
 public function export_list_data($module, $module_id, $type, $view_id = 0)
 {
     $file_name = $module;
     $object = new $module();
     $do_crm_fields = new CRMFields();
     $do_crm_list_view = new CRMListView();
     $fields_info = $do_crm_list_view->get_listview_field_info($module, $module_id, "list", $view_id);
     $entity_table_name = $object->getTable();
     $security_where = "";
     $security_where = $_SESSION["do_crm_action_permission"]->get_user_where_condition($entity_table_name, $module_id);
     $additional_where_condition = '';
     $group_by = '';
     $order_by = '';
     $object->get_list_query();
     $qry = $object->getSqlQuery();
     if (property_exists($object, "list_query_group_by") === true && $object->list_query_group_by != '') {
         $group_by = " group by " . $object->list_query_group_by;
     }
     if ($object->get_default_order_by() != "") {
         $order_by = " order by " . $object->get_default_order_by();
     }
     if ((int) $view_id > 0) {
         $do_custom_view_filter = new CustomViewFilter();
         $custom_view_date_filter_qry = $do_custom_view_filter->parse_custom_view_date_filter($view_id);
         $custom_view_adv_filter_qry = $do_custom_view_filter->parse_custom_view_advanced_filter($view_id);
         $additional_where_condition .= ' ' . $custom_view_date_filter_qry;
         if (false !== $custom_view_adv_filter_qry) {
             $additional_where_condition .= ' ' . $custom_view_adv_filter_qry["where"];
         }
         $qry .= $security_where . $additional_where_condition . $group_by . $order_by;
         if (false !== $custom_view_adv_filter_qry) {
             $this->query($qry, $custom_view_adv_filter_qry["bind_params"]);
         } else {
             $this->query($qry);
         }
     } else {
         $this->query($qry . $security_where . $group_by . $order_by);
     }
     $this->export_data($file_name, $fields_info, $type, $module_id);
 }
示例#2
0
文件: listdata.php 项目: sQcrm/sqcrm
        if (is_array($method_param) && count($method_param) > 0) {
            call_user_func_array(array($object, $method), $method_param);
            $method_param_used = true;
        } else {
            $object->{$method}();
        }
    } else {
        $object->{$method}();
    }
} else {
    $do_crm_list_view = new CRMListView();
    $object = $do_crm_list_view->get_list_view_object($m, "list");
    $object->get_list_query();
    //check if the custom view is on and get the date filter and advanced filter query
    if (isset($_REQUEST["custom_view_id"]) && (int) $_REQUEST["custom_view_id"] > 0) {
        $do_custom_view_filter = new CustomViewFilter();
        $additional_where_condition = '';
        $custom_view_date_filter_qry = $do_custom_view_filter->parse_custom_view_date_filter((int) $_REQUEST["custom_view_id"]);
        $custom_view_adv_filter_qry = $do_custom_view_filter->parse_custom_view_advanced_filter((int) $_REQUEST["custom_view_id"]);
        $additional_where_condition .= ' ' . $custom_view_date_filter_qry;
        //print_r($custom_view_adv_filter_qry);
        if (false !== $custom_view_adv_filter_qry) {
            $additional_where_condition = ' ' . $custom_view_adv_filter_qry["where"];
            $do_data_display->set_ds_additional_query_param($custom_view_adv_filter_qry["bind_params"]);
        }
        $do_data_display->set_ds_additional_where($additional_where_condition);
    }
}
$entity_table_name = $object->getTable();
//CRMListView::get_listview_field_info() sets the list_view_field_information
$fields_info = $object->list_view_field_information;
 /**
  * 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);
     }
 }
示例#4
0
文件: edit.php 项目: sQcrm/sqcrm
            $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';
}