Add php files

This commit is contained in:
2025-05-12 15:44:39 +00:00
parent c951760058
commit 82d5804ac4
9534 changed files with 2638137 additions and 0 deletions

342
modules/EcmPrices/EcmPrice.php Executable file
View File

@@ -0,0 +1,342 @@
<?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 EcmPrice 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 $active;
var $description;
var $exchange_rate_name;
var $exchange_rate_id;
var $account_name;
var $account_id;
var $lead_name;
var $lead_id;
var $price;
var $ecmlanguage;
// 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 = 'EcmPrices';
var $table_name = "ecmprices";
var $object_name = "EcmPrice";
//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 EcmPrice() {
if(!$_REQUEST['isDuplicate'] && $_REQUEST['action']=="EditView")$_SESSION['pricebook_duplicate_id']="";
parent::SugarBean();
$this->setupCustomFields('EcmPrices');
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 .= "
ecmprices.*";
if($_REQUEST['pricebook_product_id'])$query.=" ,ecmprices_ecmproducts.price as price";
$query.=",users.user_name as assigned_user_name";
if($custom_join){
$query .= $custom_join['select'];
}
$query .= " FROM ecmprices
LEFT JOIN users
ON ecmprices.assigned_user_id=users.id";
if($_REQUEST['pricebook_product_id'])$query.=" LEFT JOIN ecmprices_ecmproducts
ON ecmprices_ecmproducts.ecmprice_id=ecmprices.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($_REQUEST['pricebook_product_id'])$query.=" AND ecmprices_ecmproducts.ecmproduct_id='".$_REQUEST['pricebook_product_id']."'";
//if($_REQUEST['exchange_rate_id'])$query.=" AND ecmprices.exchange_rate_id='".$_REQUEST['exchange_rate_id']."'";
if($_GET['pricebook_id'])$query.=" AND ecmprices.id='".$_GET['pricebook_id']."'";
if(substr_count($order_by, '.') > 0){
$query .= " ORDER BY $order_by";
}
else if($order_by != "")
$query .= " ORDER BY $order_by";
else
$query .= " ORDER BY ecmprices.name";
//echo $query;
return $query;
}
/*
function create_new_list_query($order_by, $where, $show_deleted = 0){
// Fill in the assigned_user_name
$custom_join = $this->custom_fields->getJOIN();
if($_REQUEST['pricebook_product_id']){
$w=$GLOBALS['db']->query("select distinct ecmprice_id from ecmprices_ecmproducts where deleted='0' and ecmproduct_id='".$_REQUEST['pricebook_product_id']."'");
while($r=$GLOBALS['db']->fetchByAssoc($w))$arr[]="ecmprices.id like '".$r['ecmprice_id']."'";
$wpr="( ".implode(" or ",$arr)." )";
}
$select = "SELECT ";
$select .= "ecmprices.*";
$select.=",users.user_name as assigned_user_name";
if($custom_join){
$select .= $custom_join['select'];
}
$from = " FROM ecmprices LEFT JOIN users ON ecmprices.assigned_user_id=users.id";
if($custom_join){
$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 != "")
$wh= "where $where AND ".$where_auto;
else
$wh = "where ".$where_auto;
if($_REQUEST['pricebook_product_id']){
$wh.=" and ".$wpr;
}
if(substr_count($order_by, '.') > 0)$ob= " ORDER BY $order_by";
else if($order_by != "")$ob = " ORDER BY $order_by";
else $ob = " ORDER BY ecmprices.name";
$query['select']=$select;
$query['from']=$from;
$query['where']=$wh;
$query['order_by']=$ob;
$GLOBALS['db']->query($query['select']." ".$query['from']." ".$query['where']." ".$query['order_by']);
print $query['select']." ".$query['from']." ".$query['where']." ".$query['order_by'];
print mysql_error();
return $query;
}
*/
function create_export_query($order_by, $where){
$custom_join = $this->custom_fields->getJOIN();
$query = "SELECT
ecmprices.*,
users.user_name assigned_user_name";
if($custom_join){
$query .= $custom_join['select'];
}
$query .= " FROM ecmprices ";
$query .= " LEFT JOIN users
ON ecmprices.assigned_user_id=users.id";
if($custom_join){
$query .= $custom_join['join'];
}
$query .= "";
$where_auto = " ecmprices.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 ecmprices.name";
return $query;
}
function fill_in_additional_list_fields(){
if ($this->active==1)
$this->active='yes';
else
$this->active='no';
}
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,$current_user;
$the_array = parent::get_list_view_data();
$app_list_strings = return_app_list_strings_language($current_language);
$mod_strings = return_module_language($current_language, 'EcmPrices');
// 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 * from ecmprices where id='".$this->id."'"));
require_once('modules/Currencies/Currency.php');
$currency = new Currency();
$currency->retrieve($r['exchange_rate_id']);
$the_array['EXCHANGE_RATE_NAME'] = $currency->iso4217;
$w=$GLOBALS['db']->query("select price,recipient_code from ecmprices_ecmproducts where ecmproduct_id='".$_REQUEST['pricebook_product_id']."' and ecmprice_id='".$this->id."' and deleted='0'");
$r=$GLOBALS['db']->fetchByAssoc($w);
//$the_array['LIST_PRICE']=number_format($r['price'],2,$GLOBALS['sugar_config']['default_decimal_seperator'],$GLOBALS['sugar_config']['default_number_grouping_seperator']);
$the_array['PRICE']=number_format($r['price'],2,$GLOBALS['sugar_config']['default_decimal_seperator'],$GLOBALS['sugar_config']['default_number_grouping_seperator']);
$the_array['RECIPIENT_CODE']=$r['recipient_code'];
if(mysql_num_rows($w)==0)$the_array['LIST_PRICE']=$mod_strings['LBL_NO_ON_THIS_PRICEBOOK'];
require_once("modules/EcmProducts/EcmProduct.php");
$prod=new EcmProduct();
$prod->retrieve($_REQUEST['pricebook_product_id']);
$prod->format_all_fields();
$the_array['INDEX']=$prod->product_index;
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, "ecmprices.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("ECMPRICES_DESCRIPTION", $ecmprices->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);
}
}
?>