setupCustomFields('EcmPriceBooks'); 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 .= " ecmpricebooks.*"; if($_REQUEST['pricebook_product_id'])$query.=" ,ecmpricebooks_ecmproducts.price as price"; $query.=",users.user_name as assigned_user_name"; if($custom_join){ $query .= $custom_join['select']; } $query .= " FROM ecmpricebooks LEFT JOIN users ON ecmpricebooks.assigned_user_id=users.id"; if($_REQUEST['pricebook_product_id'])$query.=" LEFT JOIN ecmpricebooks_ecmproducts ON ecmpricebooks_ecmproducts.ecmpricebook_id=ecmpricebooks.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 ecmpricebooks_ecmproducts.ecmproduct_id='".$_REQUEST['pricebook_product_id']."'"; //if($_REQUEST['exchange_rate_id'])$query.=" AND ecmpricebooks.exchange_rate_id='".$_REQUEST['exchange_rate_id']."'"; if($_GET['pricebook_id'])$query.=" AND ecmpricebooks.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 ecmpricebooks.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 ecmpricebook_id from ecmpricebooks_ecmproducts where deleted='0' and ecmproduct_id='".$_REQUEST['pricebook_product_id']."'"); while($r=$GLOBALS['db']->fetchByAssoc($w))$arr[]="ecmpricebooks.id like '".$r['ecmpricebook_id']."'"; $wpr="( ".implode(" or ",$arr)." )"; } $select = "SELECT "; $select .= "ecmpricebooks.*"; $select.=",users.user_name as assigned_user_name"; if($custom_join){ $select .= $custom_join['select']; } $from = " FROM ecmpricebooks LEFT JOIN users ON ecmpricebooks.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 ecmpricebooks.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 ecmpricebooks.*, users.user_name assigned_user_name"; if($custom_join){ $query .= $custom_join['select']; } $query .= " FROM ecmpricebooks "; $query .= " LEFT JOIN users ON ecmpricebooks.assigned_user_id=users.id"; if($custom_join){ $query .= $custom_join['join']; } $query .= ""; $where_auto = " ecmpricebooks.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 ecmpricebooks.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, 'EcmPriceBooks'); // 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 == "") ? "blank" : $this->name); $the_array['ENCODED_NAME'] = $this->name; $r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select * from ecmpricebooks 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 ecmpricebooks_ecmproducts where ecmproduct_id='".$_REQUEST['pricebook_product_id']."' and ecmpricebook_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, "ecmpricebooks.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("ECMPRICEBOOKS_DESCRIPTION", $ecmpricebooks->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); } } ?>