query($z); } $file_id=add_file("filename",$_REQUEST['record'],"ecmdocs","modules/EcmDocs/files/"); if($_REQUEST['return_module']=="MySettings")$_REQUEST['return_module']="EcmDocuments"; if($_REQUEST['return_action']=="LoadTabSubpanels")$_REQUEST['return_action']="DetailView"; $focus = new EcmDoc(); $r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name from ecmdocs_group where id='".$_POST['group_id']."'")); $group_name=$r['name']; $file = "modules/Accounts/Account.php"; if(file_exists($file)) { require_once($file); $acc = new Account(); $acc->retrieve($_POST['account_id']); $_POST['account_name'] = $acc->name; } $file = "modules/Contacts/Contact.php"; if(file_exists($file)) { require_once($file); $con = new Contact(); $con->retrieve($_POST['contact_id']); $_POST['contact_name'] = $con->full_name; } $focus->retrieve($_POST['record']); if(!$focus->ACLAccess('Save')){ ACLController::displayNoAccess(true); sugar_cleanup(true); } if (!empty($_POST['assigned_user_id']) && ($focus->assigned_user_id != $_POST['assigned_user_id']) && ($_POST['assigned_user_id'] != $current_user->id)) { $check_notify = TRUE; }else{ $check_notify = FALSE; } foreach($focus->column_fields as $field){ if(isset($_POST[$field])){ $value = $_POST[$field]; $focus->$field = $value; } } foreach($focus->additional_column_fields as $field){ if(isset($_POST[$field])){ $value = $_POST[$field]; $focus->$field = $value; } } $focus->group_name = $group_name; $focus->file_id = $file_id; $focus->unformat_all_fields(); $focus->save($check_notify); $return_id = $focus->id; $reminder_time=1; /* if($_REQUEST['account_name']=="") { $r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select accounts.id as account_id,accounts.name as account_name from contacts inner join accounts_contacts on contacts.id=accounts_contacts.contact_id inner join accounts on accounts.id=accounts_contacts.account_id where contacts.id='".$_REQUEST['contact_id']."'")); $account_name=$r['account_name']; $account_id=$r['account_id']; $GLOBALS['db']->query("update ecmdocs set account_name='".$account_name."',account_id='".$account_id."' where id='".$return_id."'"); } */ if($_REQUEST['should_remind'] == "1") { $time=$timedate->to_db($_REQUEST['reminder_date']." ".$_REQUEST['hour'].":".$_REQUEST['minutes'].":00"); //require_once('modules/EcmDocs/getecmdocstoecmreminders.php'); $rs = $GLOBALS['db']->query("select id from ecmreminders where parent_id='".$return_id."' and status!='Held' and parent_module='EcmDocs'"); if($rs && is_resource($rs)) if(mysql_num_rows($rs)==0)addInfoToReminder($return_id,"EcmDocs",$focus->name,$focus->description,"",$time); if($_REQUEST['status']=="Held")$GLOBALS['db']->query("delete from ecmreminders where parent_id='".$return_id."' and parent_module='EcmDocs'"); $GLOBALS['db']->query("update ecmdocs set reminder_time='".$reminder_time."',date='".date("Y-m-d",strtotime($time))."',reminder_date='".$time."', hour='".date("H",strtotime($time))."', minutes='".date("i",strtotime($time))."' where id='".$return_id."'"); } else { $time=$timedate->to_db($_REQUEST['reminder_date']." ".$_REQUEST['hour'].":".$_REQUEST['minutes'].":00"); $GLOBALS['db']->query("update ecmdocs set reminder_time='-1', date='".date("Y-m-d",strtotime($time))."', reminder_date=NULL, hour=NULL, minutes=NULL where id='".$return_id."'"); } if($_REQUEST['emaildel'] && $_REQUEST['uid']) { require_once("modules/Emails/Email.php"); require_once("modules/InboundEmail/InboundEmail.php"); require_once("include/OutboundEmail/OutboundEmail.php"); $email = new Email(); $email->email2init(); $ie = new InboundEmail(); $ie->email = $email; $ie->deleteMessageOnMailServer($_REQUEST['uid']); $ie->deleteMessageFromCache($_REQUEST['uid']); imap_delete($ie->conn, $_REQUEST['uid']); $GLOBALS['db']->query("DELETE FROM email_cache WHERE message_id = '".$_REQUEST['uid']."'"); $GLOBALS['db']->query("DELETE FROM email_cache WHERE imap_uid = '".$_REQUEST['uid']."'"); //header("Location: index.php?module=Emails&action=EmailUIAjax&emailUIAction=deleteMessage&mbox=INBOX&ieId=".$_REQUEST['ieId']."&uid=".$_REQUEST['uid']."&return_id=".$return_id); } if($_REQUEST['backtoemails']==1)header("Location: index.php?module=Emails&action=index"); else handleRedirect($return_id,'EcmDocs'); ?>