setupCustomFields('EcmTransactions');
foreach($this->field_defs as $field){
$this->field_name_map[$field['name']] = $field;
}
}
function get_summary_text(){
return $this->name;
}
function create_list_query($order_by, $where, $show_deleted = 0){
$custom_join = $this->custom_fields->getJOIN();
$query ="SELECT ";
$query.="ecmtransactions.*,users.user_name as assigned_user_name";
if($custom_join)$query.=$custom_join['select'];
$query.=" FROM ecmtransactions ";
$query.="LEFT JOIN users ON ecmtransactions.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 ";
elseif($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";
elseif($order_by != "")$query .= " ORDER BY $order_by";
else $query .= " ORDER BY ecmtransactions.name";
return $query;
}
function create_export_query($order_by,$where){
$custom_join = $this->custom_fields->getJOIN();
$query ="SELECT ";
$query.="ecmtransactions.*,users.user_name as assigned_user_name";
if($custom_join)$query.=$custom_join['select'];
$query.=" FROM ecmtransactions ";
$query.="LEFT JOIN users ON ecmtransactions.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 ";
elseif($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";
elseif($order_by != "")$query .= " ORDER BY $order_by";
else $query .= " ORDER BY ecmtransactions.name";
return $query;
}
function fill_in_additional_list_fields(){
}
function fill_in_additional_detail_fields(){
parent::fill_in_additional_detail_fields();
}
function get_list_view_data(){
$GLOBALS ['db'] = new MysqlManager ();
$GLOBALS ['db']->connect ();
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,'EcmTransactions');
$the_array['NAME']=(($this->name == "") ? "blank" : $this->name);
$the_array['ENCODED_NAME']=$this->name;
$a=$GLOBALS ['db']->query ("select parent_id from ecmtransactions where id='".$this->id."'");
$id=$GLOBALS ['db']->fetchByAssoc ( $a);
$the_array ['PARENT_NAME'] = ''.$this->parent_name.'';
return $the_array;
}
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,"ecmtransactions.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,$ecmtransaction)
{
global $mod_strings,$app_list_strings;
$xtpl->assign("ECMPAYMENT_SUBJECT",$ecmtransaction->name);
return $xtpl;
}
function bean_implements($interface){
switch($interface){
case 'ACL':return true;
}
return false;
}
function RemoveRelations(){
if($this->id!=''){
$db=$GLOBALS['db'];
$zap=$db->query("select * from ecmtransactions_rel where (ecmtransaction_a_id='".$this->id."' OR ecmtransaction_b_id='".$this->id."')");
while($res=$db->fetchByAssoc($zap)){
$db->query("update ecmtransactions set settled=0 where id='".$res['ecmtransaction_a_id']."'");
$db->query("update ecmtransactions set settled=0 where id='".$res['ecmtransaction_b_id']."'");
//$db->query("delete from ecmtransactions_rel where id='".$res['id']."'");
}
$zap=$db->query("select * from ecmtransactions_rel where (ecmtransaction_a_id='".$this->id."' OR ecmtransaction_b_id='".$this->id."')");
while($res=$db->fetchByAssoc($zap)){
$db->query("delete from ecmtransactions_rel where id='".$res['id']."'");
}
}
}
function save($check_notify=FALSE){
$this->register_date = $this->payment_date;
$id=parent::save($check_notify);
mysql_query("delete from ecmtransactions_ecminvoiceouts where ecmtransaction_id='".$id."'");
for($i=0;$i<100;$i++){
if($_REQUEST['inv_id'.$i]){
mysql_query("insert into ecmtransactions_ecminvoiceouts(id,ecmtransaction_id,ecminvoiceout_id,date_entered,date_modified,deleted,created_by,modified_user_id) values('".create_guid()."','".$id."','".$_REQUEST['inv_id'.$i]."','".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."','0','".$_SESSION['authenticated_user_id']."','".$_SESSION['authenticated_user_id']."')");
}
}
$db = $GLOBALS['db'];
$db->query("UPDATE ecmtransactions SET settled='0' WHERE id='".$this->id."'");
if($check_notify==false)header("Location: index.php?module=EcmPaymentStates&action=AccountPaymentStates&account_id=".$this->parent_id);
return $id;
}
}
?>