get_user_time_format();
$time_separator = ":";
if(preg_match('/\d+([^\d])\d+([^\d]*)/s', $time_format, $match)) {
$time_separator = $match[1];
}
if(!empty($_POST[$prefix.'due_meridiem'])) {
$_POST[$prefix.'time_due'] = $timedate->merge_time_meridiem($_POST[$prefix.'time_due'],$timedate->get_time_format(true), $_POST[$prefix.'due_meridiem']);
}
if(!empty($_POST[$prefix.'start_meridiem'])) {
$_POST[$prefix.'time_start'] = $timedate->merge_time_meridiem($_POST[$prefix.'time_start'],$timedate->get_time_format(true), $_POST[$prefix.'start_meridiem']);
}
if(isset($_POST[$prefix.'time_due']) && !empty($_POST[$prefix.'time_due'])) {
$_POST[$prefix.'date_due'] = $_POST[$prefix.'date_due'] . ' ' . $_POST[$prefix.'time_due'];
}
if(isset($_POST[$prefix.'time_start']) && !empty($_POST[$prefix.'time_start'])) {
$_POST[$prefix.'date_start'] = $_POST[$prefix.'date_start'] . ' ' . $_POST[$prefix.'time_start'];
}
require_once('include/formbase.php');
$focus = populateFromPost('', $focus);
//echo '
'; die('koniec');
if(!$focus->ACLAccess('Save')){
ACLController::displayNoAccess(true);
sugar_cleanup(true);
}
if (isCloseAndCreateNewPressed()) $focus->status = 'Completed';
if (!isset($_POST['date_due_flag'])) $focus->date_due_flag = 0;
if (!isset($_POST['date_start_flag'])) $focus->date_start_flag = 0;
//if only the time is passed in, without a date, then string length will be 7
if (isset($_REQUEST['date_due']) && strlen(trim($_REQUEST['date_due']))<8 ){
//no date set, so clear out field, and set the rest flag to true
$focus->date_due_flag = 1;
$focus->date_due = '';
}
//if only the time is passed in, without a date, then string length will be 7
if (isset($_REQUEST['date_start']) && strlen(trim($_REQUEST['date_start']))<8){
//no date set, so clear out field, and set the rest flag to true
$focus->date_start_flag = 1;
$focus->date_start = '';
}
///////////////////////////////////////////////////////////////////////////////
//// INBOUND EMAIL HANDLING
///////////////////////////////////////////////////////////////////////////////
if(isset($_REQUEST['inbound_email_id']) && !empty($_REQUEST['inbound_email_id'])) {
// fake this case like it's already saved.
$focus->save();
require_once('modules/Emails/Email.php');
$email = new Email();
$email->retrieve($_REQUEST['inbound_email_id']);
$email->parent_type = 'Tasks';
$email->parent_id = $focus->id;
$email->assigned_user_id = $current_user->id;
$email->status = 'read';
$email->save();
$email->load_relationship('tasks');
$email->tasks->add($focus->id);
header("Location: index.php?&module=Emails&action=EditView&type=out&inbound_email_id=".$_REQUEST['inbound_email_id']."&parent_id=".$email->parent_id."&parent_type=".$email->parent_type.'&start='.$_REQUEST['start'].'&assigned_user_id='.$current_user->id);
exit();
}
//// END INBOUND EMAIL HANDLING
///////////////////////////////////////////////////////////////////////////////
// avoid undefined index
if (!isset($GLOBALS['check_notify'])) {
$GLOBALS['check_notify'] = false;
}
$focus->date_start = $_POST['date_start'];
$focus->date_due = $_POST['date_due'];
$focus->save($GLOBALS['check_notify']);
$return_id = $focus->id;
//
//Before
/*
handleRedirect($return_id,'Tasks');
*/
//After
if(isset($_REQUEST['save_and_create_work_item']))
header("Location: index.php?module=EcmWorkItems&action=EditView&out_module=Tasks&out_id=".$return_id);
else
handleRedirect($return_id,'Tasks');
//
?>