272 lines
8.9 KiB
PHP
272 lines
8.9 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 EcmDoc 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 $description;
|
||
|
|
var $group_id;
|
||
|
|
var $group_name;
|
||
|
|
var $account_id;
|
||
|
|
var $account_name;
|
||
|
|
var $contact_id;
|
||
|
|
var $contact_name;
|
||
|
|
var $relation;
|
||
|
|
var $value;
|
||
|
|
var $date;
|
||
|
|
var $reminder_time;
|
||
|
|
var $hour;
|
||
|
|
var $minutes;
|
||
|
|
var $reminder_date;
|
||
|
|
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 = 'EcmDocs';
|
||
|
|
var $table_name = "ecmdocs";
|
||
|
|
var $object_name = "EcmDoc";
|
||
|
|
|
||
|
|
//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
|
||
|
|
'contact_id',
|
||
|
|
'account_id'
|
||
|
|
);
|
||
|
|
|
||
|
|
function EcmDoc() {
|
||
|
|
parent::SugarBean();
|
||
|
|
$this->setupCustomFields('EcmDocs');
|
||
|
|
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_list_query($order_by, $where, $show_deleted = 0){
|
||
|
|
// Fill in the assigned_user_name
|
||
|
|
$custom_join = $this->custom_fields->getJOIN();
|
||
|
|
$query = "SELECT ";
|
||
|
|
$query .= "
|
||
|
|
ecmdocs.*
|
||
|
|
,users.user_name as assigned_user_name";
|
||
|
|
if($custom_join){
|
||
|
|
$query .= $custom_join['select'];
|
||
|
|
}
|
||
|
|
$query .= " FROM ecmdocs
|
||
|
|
LEFT JOIN users
|
||
|
|
ON ecmdocs.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 ecmdocs.name";
|
||
|
|
|
||
|
|
return $query;
|
||
|
|
}
|
||
|
|
|
||
|
|
function create_export_query($order_by, $where){
|
||
|
|
$custom_join = $this->custom_fields->getJOIN();
|
||
|
|
$query = "SELECT
|
||
|
|
ecmdocs.*,
|
||
|
|
users.user_name assigned_user_name";
|
||
|
|
if($custom_join){
|
||
|
|
$query .= $custom_join['select'];
|
||
|
|
}
|
||
|
|
$query .= " FROM ecmdocs ";
|
||
|
|
|
||
|
|
$query .= " LEFT JOIN users
|
||
|
|
ON ecmdocs.assigned_user_id=users.id";
|
||
|
|
if($custom_join){
|
||
|
|
$query .= $custom_join['join'];
|
||
|
|
}
|
||
|
|
$query .= "";
|
||
|
|
$where_auto = " ecmdocs.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 ecmdocs.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, 'EcmDocs');
|
||
|
|
|
||
|
|
// 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;
|
||
|
|
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select account_id,file_id from ecmdocs where id='".$this->id."'"));
|
||
|
|
$the_array['ACCOUNT_ID'] = $r['account_id'];
|
||
|
|
|
||
|
|
$z="select version,id,date_entered,name from ecmfiles_versions where file_id='".$r['file_id']."' and deleted='0' order by version desc limit 1";
|
||
|
|
$w=$GLOBALS['db']->query($z);
|
||
|
|
$r=$GLOBALS['db']->fetchByAssoc($w);
|
||
|
|
$the_array['PDF_LINK']='<a href="DownloadEcmFile.php?record='.$r['id'].'"><img src="modules/EcmInvoiceOuts/images/pdf.gif" border="0"></a>';
|
||
|
|
|
||
|
|
$w=$GLOBALS['db']->query("select file_id from ecmfiles_versions where file_id='".$this->file_id."'");
|
||
|
|
if(mysql_num_rows($w)>0)$the_array['BUTTON_DOWNLOAD']='<a title="PDF" href="DownloadEcmFile.php?file_id='.$this->file_id.'"><img title="PDF" src="modules/EcmDocuments/images/pdf.gif" width="14" height="14" border="0"></a>';
|
||
|
|
else $the_array['BUTTON_DOWNLOAD']='<img src="modules/EcmDocuments/images/pdf-off.gif" width="14" height="14" border="0" />';
|
||
|
|
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, "ecmdocs.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("ECMDOCS_DESCRIPTION", $ecmdocs->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);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
?>
|