302 lines
9.4 KiB
PHP
302 lines
9.4 KiB
PHP
|
|
<?php
|
||
|
|
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||
|
|
/*****************************************************************************
|
||
|
|
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||
|
|
* Version 1.1 ("License"); You may not use this file except in compliance
|
||
|
|
* with the License. You may obtain a copy of the License at
|
||
|
|
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||
|
|
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||
|
|
* either express or implied.
|
||
|
|
*
|
||
|
|
* You may:
|
||
|
|
* a) Use and distribute this code exactly as you received without payment or
|
||
|
|
* a royalty or other fee.
|
||
|
|
* b) Create extensions for this code, provided that you make the extensions
|
||
|
|
* publicly available and document your modifications clearly.
|
||
|
|
* c) Charge for a fee for warranty or support or for accepting liability
|
||
|
|
* obligations for your customers.
|
||
|
|
*
|
||
|
|
* You may NOT:
|
||
|
|
* a) Charge for the use of the original code or extensions, including in
|
||
|
|
* electronic distribution models, such as ASP (Application Service
|
||
|
|
* Provider).
|
||
|
|
* b) Charge for the original source code or your extensions other than a
|
||
|
|
* nominal fee to cover distribution costs where such distribution
|
||
|
|
* involves PHYSICAL media.
|
||
|
|
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||
|
|
* or License text in the Licensed Software
|
||
|
|
* d) Assert any patent claims against the Licensor or Contributors, or
|
||
|
|
* which would in any way restrict the ability of any third party to use the
|
||
|
|
* Licensed Software.
|
||
|
|
*
|
||
|
|
* You must:
|
||
|
|
* a) Document any modifications you make to this code including the nature of
|
||
|
|
* the change, the authors of the change, and the date of the change.
|
||
|
|
* b) Make the source code for any extensions you deploy available via an
|
||
|
|
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||
|
|
* c) Notify the licensor of the availability of source code to your extensions
|
||
|
|
* and include instructions on how to acquire the source code and updates.
|
||
|
|
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||
|
|
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||
|
|
*
|
||
|
|
* The Original Code is: CommuniCore
|
||
|
|
* Olavo Farias
|
||
|
|
* 2006-04-7 olavo.farias@gmail.com
|
||
|
|
*
|
||
|
|
* The Initial Developer of the Original Code is CommuniCore.
|
||
|
|
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||
|
|
* All Rights Reserved.
|
||
|
|
********************************************************************************/
|
||
|
|
require_once('data/SugarBean.php');
|
||
|
|
require_once('include/utils.php');
|
||
|
|
|
||
|
|
// SHOULD INCLUDE SELECTIVELY
|
||
|
|
|
||
|
|
|
||
|
|
class EcmReminder extends SugarBean {
|
||
|
|
var $field_name_map = array();
|
||
|
|
// STANDARD FIELDS
|
||
|
|
var $id;
|
||
|
|
var $date_entered;
|
||
|
|
var $date_modified;
|
||
|
|
var $modified_user_id;
|
||
|
|
var $assigned_user_id;
|
||
|
|
var $name;
|
||
|
|
|
||
|
|
//TABLE COLUMNS
|
||
|
|
var $parent_id;
|
||
|
|
var $parent_name;
|
||
|
|
var $description;
|
||
|
|
var $date_start;
|
||
|
|
var $role_id;
|
||
|
|
var $status;
|
||
|
|
|
||
|
|
// RELATED FIELDS
|
||
|
|
var $created_by;
|
||
|
|
var $created_by_name;
|
||
|
|
var $modified_by_name;
|
||
|
|
var $assigned_user_name;
|
||
|
|
|
||
|
|
// SUBPANELS RELATED
|
||
|
|
|
||
|
|
// MODULE OBJECT DETAILS
|
||
|
|
var $module_dir = 'EcmReminders';
|
||
|
|
var $table_name = "ecmreminders";
|
||
|
|
var $object_name = "EcmReminder";
|
||
|
|
|
||
|
|
//RELATED TABLE NAMES
|
||
|
|
|
||
|
|
|
||
|
|
// USED TO RETRIEVE RELATED FIELDS FROM FORM POSTS.
|
||
|
|
var $additional_column_fields = Array(
|
||
|
|
'assigned_user_name',
|
||
|
|
'assigned_user_id',
|
||
|
|
'modified_user_id',
|
||
|
|
'created_by',
|
||
|
|
);
|
||
|
|
|
||
|
|
var $relationship_fields = Array(
|
||
|
|
//RELATIONSHIP FIELDS
|
||
|
|
|
||
|
|
);
|
||
|
|
|
||
|
|
function EcmReminder() {
|
||
|
|
parent::SugarBean();
|
||
|
|
$this->setupCustomFields('EcmReminders');
|
||
|
|
foreach ($this->field_defs as $field)
|
||
|
|
{
|
||
|
|
$this->field_name_map[$field['name']] = $field;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
var $new_schema = true;
|
||
|
|
|
||
|
|
function get_summary_text(){
|
||
|
|
return "$this->name";
|
||
|
|
}
|
||
|
|
function create_new_list_query($order_by, $where, $show_deleted = 0){
|
||
|
|
// Fill in the assigned_user_name
|
||
|
|
if($_REQUEST['module']=="Home")
|
||
|
|
{
|
||
|
|
$custom_join = $this->custom_fields->getJOIN();
|
||
|
|
$query['select'] = "SELECT ";
|
||
|
|
$query['select'] .= "
|
||
|
|
ecmreminders.*
|
||
|
|
,users.user_name as assigned_user_name";
|
||
|
|
if($custom_join){
|
||
|
|
$query .= $custom_join['select'];
|
||
|
|
}
|
||
|
|
$query['from'] .= " FROM ecmreminders
|
||
|
|
LEFT JOIN users
|
||
|
|
ON ecmreminders.assigned_user_id=users.id";
|
||
|
|
|
||
|
|
|
||
|
|
$query['from'] .= " ";
|
||
|
|
if($custom_join){
|
||
|
|
$query['from'] .= $custom_join['join'];
|
||
|
|
}
|
||
|
|
$where_auto = '1=1';
|
||
|
|
if($show_deleted == 0){
|
||
|
|
$where_auto = " $this->table_name.deleted=0 ";
|
||
|
|
}else if($show_deleted == 1){
|
||
|
|
$where_auto = " $this->table_name.deleted=1 ";
|
||
|
|
}
|
||
|
|
|
||
|
|
if($where != "")
|
||
|
|
$query['where'] .= "where $where AND ".$where_auto;
|
||
|
|
else
|
||
|
|
$query['where'] .= "where ".$where_auto;
|
||
|
|
if(substr_count($order_by, '.') > 0){
|
||
|
|
$query['order_by'] .= " ORDER BY $order_by";
|
||
|
|
}
|
||
|
|
else if($order_by != "")
|
||
|
|
$query['order_by'] .= " ORDER BY $order_by";
|
||
|
|
else
|
||
|
|
$query['order_by'] .= " ORDER BY ecmreminders.name";
|
||
|
|
|
||
|
|
return $query;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
|
||
|
|
$ret_array['select']="select calls.*,meetings.*,ecmreminders.* ";
|
||
|
|
$ret_array['from']="from calls,meetings,ecmreminders ";
|
||
|
|
$ret_array['where']="where calls.deleted='0' and meetings.deleted='0' and ecmreminders.deleted='0' ";
|
||
|
|
$ret_array['order_by']="";
|
||
|
|
|
||
|
|
return $ret_array;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
function create_list_query($order_by, $where, $show_deleted = 0){
|
||
|
|
// Fill in the assigned_user_name
|
||
|
|
$custom_join = $this->custom_fields->getJOIN();
|
||
|
|
$query = "SELECT ";
|
||
|
|
$query .= "
|
||
|
|
ecmreminders.*
|
||
|
|
,users.user_name as assigned_user_name";
|
||
|
|
if($custom_join){
|
||
|
|
$query .= $custom_join['select'];
|
||
|
|
}
|
||
|
|
$query .= " FROM ecmreminders
|
||
|
|
LEFT JOIN users
|
||
|
|
ON ecmreminders.assigned_user_id=users.id";
|
||
|
|
|
||
|
|
|
||
|
|
$query .= " ";
|
||
|
|
if($custom_join){
|
||
|
|
$query .= $custom_join['join'];
|
||
|
|
}
|
||
|
|
$where_auto = '1=1';
|
||
|
|
if($show_deleted == 0){
|
||
|
|
$where_auto = " $this->table_name.deleted=0 ";
|
||
|
|
}else if($show_deleted == 1){
|
||
|
|
$where_auto = " $this->table_name.deleted=1 ";
|
||
|
|
}
|
||
|
|
|
||
|
|
if($where != "")
|
||
|
|
$query .= "where $where AND ".$where_auto;
|
||
|
|
else
|
||
|
|
$query .= "where ".$where_auto;
|
||
|
|
if(substr_count($order_by, '.') > 0){
|
||
|
|
$query .= " ORDER BY $order_by";
|
||
|
|
}
|
||
|
|
else if($order_by != "")
|
||
|
|
$query .= " ORDER BY $order_by";
|
||
|
|
else
|
||
|
|
$query .= " ORDER BY ecmreminders.name";
|
||
|
|
|
||
|
|
return $query;
|
||
|
|
}
|
||
|
|
function create_export_query($order_by, $where){
|
||
|
|
$custom_join = $this->custom_fields->getJOIN();
|
||
|
|
$query = "SELECT
|
||
|
|
ecmreminders.*,
|
||
|
|
users.user_name assigned_user_name";
|
||
|
|
if($custom_join){
|
||
|
|
$query .= $custom_join['select'];
|
||
|
|
}
|
||
|
|
$query .= " FROM ecmreminders ";
|
||
|
|
|
||
|
|
$query .= " LEFT JOIN users
|
||
|
|
ON ecmreminders.assigned_user_id=users.id";
|
||
|
|
if($custom_join){
|
||
|
|
$query .= $custom_join['join'];
|
||
|
|
}
|
||
|
|
$query .= "";
|
||
|
|
$where_auto = " ecmreminders.deleted=0
|
||
|
|
";
|
||
|
|
|
||
|
|
if($where != "")
|
||
|
|
$query .= " where $where AND ".$where_auto;
|
||
|
|
else
|
||
|
|
$query .= " where ".$where_auto;
|
||
|
|
|
||
|
|
if($order_by != "")
|
||
|
|
$query .= " ORDER BY $order_by";
|
||
|
|
else
|
||
|
|
$query .= " ORDER BY ecmreminders.name";
|
||
|
|
|
||
|
|
return $query;
|
||
|
|
}
|
||
|
|
|
||
|
|
function fill_in_additional_list_fields(){
|
||
|
|
}
|
||
|
|
|
||
|
|
function fill_in_additional_detail_fields(){
|
||
|
|
// FILL IN THE ASSIGNED_USER_NAME
|
||
|
|
$this->assigned_user_name = get_assigned_user_name($this->assigned_user_id);
|
||
|
|
$this->created_by_name = get_assigned_user_name($this->created_by);
|
||
|
|
$this->modified_by_name = get_assigned_user_name($this->modified_user_id);
|
||
|
|
}
|
||
|
|
|
||
|
|
function get_list_view_data(){
|
||
|
|
global $current_language;
|
||
|
|
$the_array = parent::get_list_view_data();
|
||
|
|
$app_list_strings = return_app_list_strings_language($current_language);
|
||
|
|
$mod_strings = return_module_language($current_language, 'EcmReminders');
|
||
|
|
|
||
|
|
// THE NEW LISTVIEW CODE ONLY FETCHES COLUMNS THAT WE'RE DISPLAYING AND NOT ALL
|
||
|
|
// THE COLUMNS SO WE NEED THESE CHECKS.
|
||
|
|
$the_array['NAME'] = (($this->name == "") ? "<em>blank</em>" : $this->name);
|
||
|
|
$the_array['ENCODED_NAME'] = $this->name;
|
||
|
|
return $the_array;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
BUILDS A GENERIC SEARCH BASED ON THE QUERY STRING USING OR.
|
||
|
|
DO NOT INCLUDE ANY $THIS-> BECAUSE THIS IS CALLED ON WITHOUT HAVING THE CLASS INSTANTIATED.
|
||
|
|
*/
|
||
|
|
function build_generic_where_clause ($the_query_string) {
|
||
|
|
$where_clauses = Array();
|
||
|
|
$the_query_string = PearDatabase::quote(from_html($the_query_string));
|
||
|
|
array_push($where_clauses, "ecmreminders.name like '$the_query_string%'");
|
||
|
|
|
||
|
|
$the_where = "";
|
||
|
|
foreach($where_clauses as $clause){
|
||
|
|
if($the_where != "") $the_where .= " or ";
|
||
|
|
$the_where .= $clause;
|
||
|
|
}
|
||
|
|
return $the_where;
|
||
|
|
}
|
||
|
|
|
||
|
|
function set_notification_body($xtpl, $simplemodule){
|
||
|
|
global $mod_strings, $app_list_strings;
|
||
|
|
|
||
|
|
$xtpl->assign("NAME", $simplemodule->name);
|
||
|
|
$xtpl->assign("ECMREMINDERS_DESCRIPTION", $ecmreminders->description);
|
||
|
|
return $xtpl;
|
||
|
|
}
|
||
|
|
|
||
|
|
function bean_implements($interface){
|
||
|
|
switch($interface){
|
||
|
|
case 'ACL':return true;
|
||
|
|
}
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
function save($check_notify = FALSE){
|
||
|
|
return parent::save($check_notify);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
?>
|