/** Import tasks from another project * * @param int Project ID of the tasks come from. * @return bool **/ function importTasks($from_project_id, $scale_project = false) { // Load the original $origProject = new CProject(); $origProject->load($from_project_id); $q = new DBQuery(); $q->addTable('tasks'); $q->addQuery('task_id'); $q->addWhere('task_project =' . $from_project_id); $sql = $q->prepare(); $q->clear(); $tasks = array_flip(db_loadColumn($sql)); //Pristine Start and End Dates of Source and Destination Projects $origStartDate = new CDate($origProject->project_start_date); $origEndDate = new CDate($origProject->project_end_date); $destStartDate = new CDate($this->project_start_date); $destEndDate = new CDate($this->project_end_date); $dateOffset = $destStartDate->dateDiff($origStartDate); //Check that we have enough information to scale properly //(i.e. no information is missing or "zero") if (empty($origProject->project_start_date) || empty($origProject->project_end_date) || empty($this->project_start_date) || empty($this->project_end_date) || $origProject->project_start_date == '0000-00-00 00:00:00' || $origProject->project_end_date == '0000-00-00 00:00:00' || $this->project_start_date == '0000-00-00 00:00:00' || $this->project_end_date == '0000-00-00 00:00:00') { $scale_project = false; } if ($scale_project) { //get ratio for scaling, protect from division by 0 $ratio = (abs($destEndDate->dateDiff($destStartDate)) + 1) / (abs($origEndDate->dateDiff($origStartDate)) + 1); } // Old dependencies array from imported tasks $deps = array(); // New dependencies array for new copies of imported tasks $newDeps = array(); // Old2New task ID array $taskXref = array(); // New task ID to old parent array $nid2op = array(); // Copy each task into this project and get their deps foreach ($tasks as $orig => $void) { $objTask = new CTask(); $objTask->load($orig); // Grab the old parent id $oldParent = (int) $objTask->task_parent; $deps[$orig] = $objTask->getDependencies(); $destTask = $objTask->copy($this->project_id, 0); $nid2op[$destTask->task_id] = $oldParent; $tasks[$orig] = $destTask; $taskXref[$orig] = (int) $destTask->task_id; } // Build new dependencies array foreach ($deps as $odkey => $od) { $ndt = ''; $ndkey = $taskXref[$odkey]; $odep = explode(',', $od); foreach ($odep as $odt) { $ndt = $ndt . $taskXref[$odt] . ','; } $ndt = rtrim($ndt, ','); $newDeps[$ndkey] = $ndt; } $q->addTable('tasks'); $q->addQuery('task_id'); $q->addWhere('task_project =' . $this->project_id); $tasks = $q->loadColumn(); // Update dates based on new project's start date. $origDate = new CDate($origProject->project_start_date); $origStartHour = new CDate($this->project_start_date); $destDate = new CDate($this->project_start_date); foreach ($tasks as $task_id) { $newTask = new CTask(); $newTask->load($task_id); if (in_array($task_id, $taskXref)) { $task_date_vars = array('task_start_date', 'task_end_date'); //Adjust task dates based on calculated offsets foreach ($task_date_vars as $my_date) { if (!empty($newTask->{$my_date}) && $newTask->{$my_date} != '0000-00-00 00:00:00') { $origDate->setDate($newTask->{$my_date}); $origStartHour->setDate($newTask->{$my_date}); $origStartHour->setTime(intval(dPgetConfig('cal_day_start'))); $destDate->setDate($newTask->{$my_date}); $destDate->addDays($dateOffset); if ($scale_project) { $offsetAdd = round($origDate->dateDiff($origStartDate) * $ratio) - $origDate->dateDiff($origStartDate); $destDate->addDays($offsetAdd); $hours_in = $origStartHour->calcDuration($origDate); $offsetAddHours = round($hours_in * $ratio) - $hours_in; if ($offsetAddHours % dPgetConfig('daily_working_hours')) { $destDate->addDuration($offsetAddHours); } } $destDate = $destDate->next_working_day(); $newTask->{$my_date} = $destDate->format(FMT_DATETIME_MYSQL); } } //Adjust durration to scale if ($scale_project) { $newTask->task_duration = round($newTask->task_duration * $ratio, 2); } $newTask->task_parent = $taskXref[$nid2op[$newTask->task_id]]; $newTask->store(); $newTask->updateDependencies($newDeps[$task_id]); } // end check if imported task $newTask->store(); } // end Fix record integrity }
* 否则把$_POST数组中的变量,绑定到对象中 */ if (!$obj->bind($_POST)) { $AppUI->setMsg($obj->getError(), UI_MSG_ERROR); $AppUI->redirect(); } require_once $AppUI->getSystemClass('CustomFields'); //一些转化 // convert dates to SQL format first if ($obj->project_start_date) { $date = new CDate($obj->project_start_date); $obj->project_start_date = $date->format(FMT_DATETIME_MYSQL); } if ($obj->project_end_date) { $date = new CDate($obj->project_end_date); $date->setTime(23, 59, 59); $obj->project_end_date = $date->format(FMT_DATETIME_MYSQL); } if ($obj->project_actual_end_date) { $date = new CDate($obj->project_actual_end_date); $obj->project_actual_end_date = $date->format(FMT_DATETIME_MYSQL); } // let's check if there are some assigned departments to project //部门分配 if (!dPgetParam($_POST, "project_departments", 0)) { //返回一个部门的id $obj->project_departments = implode(",", dPgetParam($_POST, "dept_ids", array())); } $del = dPgetParam($_POST, 'del', 0); // prepare (and translate) the module name ready for the suffix if ($del) {
$q->clear(); $caption = substr($caption, 0, strlen($caption) - 1); /* if (function_exists('iconv') && function_exists('mb_detect_encoding')) { $caption = iconv(mb_detect_encoding($caption." "), 'UTF-8', $caption); } */ $caption = strUTF8Decode($caption); // if (function_exists('utf8_decode')) { // $caption = utf8_decode($caption); // } } if ($flags == 'm') { // if hide milestones is ticked this bit is not processed////////////////////////////////////////// if ($showNoMilestones != '1') { $start_date_mile = new CDate($start_date); $start_date_mile->setTime(0); $start_mile = $start_date_mile->getDate(); $s = $start_date->format($df); $today_date = date('m/d/Y'); $today_date_stamp = strtotime($today_date); $mile_date = $start_date->format("%m/%d/%Y"); $mile_date_stamp = strtotime($mile_date); // honour the choice to show task names only/////////////////////////////////////////////////// if ($showTaskNameOnly == '1') { if ($caller == 'todo') { $milestone_label_array = array($name); } else { $milestone_label_array = array($name); } $bar = new MileStone($row++, $milestone_label_array, $start_mile, $s); if ($monospacefont) {
$AppUI->setState('TimecardMonthlyUserId', $AppUI->user_id); } $user_id = $AppUI->getState('TimecardMonthlyUserId') ? $AppUI->getState('TimecardMonthlyUserId') : 0; } else { $user_id = $AppUI->user_id; } $start_report = new CDate(); $start_report->setMonth($month); $start_report->setYear($year); $start_report->setDay(1); $start_report->setTime(0, 0, 0); $end_report = new CDate(); $end_report->copy($start_report); $end_report->addMonths(1); $end_report->addDays(-1); $end_report->setTime(23, 59, 59); //Get hash of users $sql = "SELECT user_id, contact_email, concat(contact_last_name,' ',contact_first_name) as name FROM users LEFT JOIN contacts AS c ON users.user_contact = contact_id ORDER BY contact_last_name, contact_first_name;"; $result = db_loadList($sql); $people = array(); // users list foreach ($result as $row) { $people[$row['user_id']] = $row; $users[$row['user_id']] = $row['name']; } unset($result); $sql = "\r\n select distinct(project_id), project_name from task_log\r\n left join tasks on tasks.task_id = task_log.task_log_task\r\n left join projects on projects.project_id = tasks.task_project\r\n where\r\n task_log_date >= '" . $start_report->format(FMT_DATETIME_MYSQL) . "'\r\n and task_log_date <= '" . $end_report->format(FMT_DATETIME_MYSQL) . "'\r\n and task_log_task != 0\r\n and task_log_creator = " . $user_id . "\r\n order by project_name\r\n\t\t"; # echo $sql; $projects = array(); $result = db_loadList($sql); foreach ($result as $row) {
$AppUI->setState('CalIdxCompany', intval(w2PgetParam($_REQUEST, 'company_id', 0))); } $company_id = $AppUI->getState('CalIdxCompany') !== null ? $AppUI->getState('CalIdxCompany') : $AppUI->user_company; $event_filter = $AppUI->checkPrefState('CalIdxFilter', w2PgetParam($_REQUEST, 'event_filter', ''), 'EVENTFILTER', 'my'); // get the passed timestamp (today if none) $date = w2PgetParam($_GET, 'date', null); // establish the focus 'date' $this_week = new CDate($date); $dd = $this_week->getDay(); $mm = $this_week->getMonth(); $yy = $this_week->getYear(); // prepare time period for 'events' $first_time = new CDate(Date_calc::beginOfWeek($dd, $mm, $yy, FMT_TIMESTAMP_DATE, LOCALE_FIRST_DAY)); $first_time->setTime(0, 0, 0); $last_time = new CDate(Date_calc::endOfWeek($dd, $mm, $yy, FMT_TIMESTAMP_DATE, LOCALE_FIRST_DAY)); $last_time->setTime(23, 59, 59); $prev_week = new CDate(Date_calc::beginOfPrevWeek($dd, $mm, $yy, FMT_TIMESTAMP_DATE, LOCALE_FIRST_DAY)); $next_week = new CDate(Date_calc::beginOfNextWeek($dd, $mm, $yy, FMT_TIMESTAMP_DATE, LOCALE_FIRST_DAY)); $links = array(); // assemble the links for the tasks require_once W2P_BASE_DIR . '/modules/calendar/links_tasks.php'; getTaskLinks($first_time, $last_time, $links, 50, $company_id); // assemble the links for the events require_once W2P_BASE_DIR . '/modules/calendar/links_events.php'; getEventLinks($first_time, $last_time, $links, 50); // get the list of visible companies $company = new CCompany(); $companies = $company->getAllowedRecords($AppUI->user_id, 'company_id,company_name', 'company_name'); $companies = arrayMerge(array('0' => $AppUI->_('All')), $companies); // setup the title block $titleBlock = new CTitleBlock('Week View', 'myevo-appointments.png', $m, "{$m}.{$a}");
if ($msg = $obj->store()) { $AppUI->setMsg($msg, UI_MSG_ERROR); $AppUI->redirect(); } else { $AppUI->setMsg(@$_POST['task_log_id'] ? 'updated' : 'inserted', UI_MSG_OK, true); } } $task = new CTask(); $task->load($obj->task_log_task); $task->htmlDecode(); $task->check(); $task_end_date = new CDate($task->task_end_date); $task->task_percent_complete = dPgetParam($_POST, 'task_percent_complete', null); if (dPgetParam($_POST, 'task_end_date', '') != '') { $new_date = new CDate($_POST['task_end_date']); $new_date->setTime($task_end_date->hour, $task_end_date->minute, $task_end_date->second); $task->task_end_date = $new_date->format(FMT_DATETIME_MYSQL); } if ($task->task_percent_complete >= 100 && (!$task->task_end_date || $task->task_end_date == '0000-00-00 00:00:00')) { $task->task_end_date = $obj->task_log_date; } if ($msg = $task->store()) { $AppUI->setMsg($msg, UI_MSG_ERROR, true); } $new_task_end = new CDate($task->task_end_date); if ($new_task_end->dateDiff($task_end_date)) { $task->addReminder(); } if ($notify_owner && ($msg = $task->notifyOwner())) { $AppUI->setMsg($msg, UI_MSG_ERROR); }
function clash_suggest() { global $AppUI, $m, $a; $obj =& new CEvent(); $obj->bind($_SESSION['add_event_post']); $start_date =& new CDate($obj->event_start_date); $end_date =& new CDate($obj->event_end_date); $df = $AppUI->getPref('SHDATEFORMAT'); $start_secs = $start_date->getTime(); $end_secs = $end_date->getTime(); $duration = (int) (($end_secs - $start_secs) / 60); $titleBlock =& new CTitleBlock('Suggest Alternative Event Time', 'myevo-appointments.png', $m, $m . '.' . $a); $titleBlock->show(); $calurl = DP_BASE_URL . '/index.php?m=calendar&a=clash&event_id=' . $obj->event_id; $times = array(); $t = new CDate(); $t->setTime(0, 0, 0); if (!defined('LOCALE_TIME_FORMAT')) { define('LOCALE_TIME_FORMAT', '%I:%M %p'); } for ($m = 0; $m < 60; $m++) { $times[$t->format("%H%M%S")] = $t->format(LOCALE_TIME_FORMAT); $t->addSeconds(1800); } ?> <script language="javascript"> var calendarField = ''; function popCalendar(field){ calendarField = field; idate = eval('document.editFrm.event_' + field + '.value'); window.open('index.php?m=public&a=calendar&dialog=1&callback=setCalendar&date=' + idate, 'calwin', 'top=250,left=250,width=250, height=220, scrollbars=no, status=no'); } /** * @param string Input date in the format YYYYMMDD * @param string Formatted date */ function setCalendar(idate, fdate) { fld_date = eval('document.editFrm.event_' + calendarField); fld_fdate = eval('document.editFrm.' + calendarField); fld_date.value = idate; fld_fdate.value = fdate; } function set_clash_action(action) { document.editFrm.clash_action.value = action; document.editFrm.submit(); } </script> <form name='editFrm' method='POST' action='<?php echo "{$calurl}&clash_action=process"; ?> '> <table width='100%' class='std'> <tr> <td width='50%' align='right'><?php echo $AppUI->_('Earliest Date'); ?> :</td> <td width='50%' align='left' nowrap="nowrap"> <input type="hidden" name="event_start_date" value="<?php echo $start_date->format(FMT_TIMESTAMP_DATE); ?> "> <input type="text" name="start_date" value="<?php echo $start_date->format($df); ?> " class="text" disabled="disabled"> <a href="#" onClick="popCalendar('start_date')"> <img src="./images/calendar.gif" width="24" height="12" alt="<?php echo $AppUI->_('Calendar'); ?> " border="0" /> </a> </td> </tr> <tr> <td width='50%' align='right'><?php echo $AppUI->_('Latest Date'); ?> :</td> <td width='50%' align='left' nowrap="nowrap"> <input type="hidden" name="event_end_date" value="<?php echo $end_date->format(FMT_TIMESTAMP_DATE); ?> "> <input type="text" name="end_date" value="<?php echo $end_date->format($df); ?> " class="text" disabled="disabled"> <a href="#" onClick="popCalendar('end_date')"> <img src="./images/calendar.gif" width="24" height="12" alt="<?php echo $AppUI->_('Calendar'); ?> " border="0" /> </a> </td> </tr> <tr> <td width='50%' align='right'><?php echo $AppUI->_('Earliest Start Time'); ?> :</td> <td width='50%' align='left'> <?php echo arraySelect($times, 'start_time', 'size="1" class="text"', $start_date->format("%H%M%S")); ?> </td> </tr> <tr> <td width='50%' align='right'><?php echo $AppUI->_('Latest Finish Time'); ?> :</td> <td width='50%' align='left'> <?php echo arraySelect($times, 'end_time', 'size="1" class="text"', $end_date->format("%H%M%S")); ?> </td> </tr> <tr> <td width='50%' align='right'><?php echo $AppUI->_('Duration'); ?> :</td> <td width='50%' align='left'> <input type="text" class="text" size=5 name="duration" value="<?php echo $duration; ?> "> <?php echo $AppUI->_('minutes'); ?> </td> </tr> <tr> <td><input type="button" value="<?php echo $AppUI->_('cancel'); ?> " class="button" onClick="set_clash_action('cancel');" /></td> <td align="right"><input type="button" value="<?php echo $AppUI->_('submit'); ?> " class="button" onClick="set_clash_action('process')" /></td> </tr> </table> <input type='hidden' name='clash_action' value='cancel'> </form> <?php }
$seldate->setTime(dPgetConfig('cal_day_start'), 0, 0); } $obj->event_start_date = $seldate->format(FMT_TIMESTAMP); if ($h && $h < dPgetConfig('cal_day_end')) { $seldate->addSeconds($inc * 60); } else { $seldate->setTime(dPgetConfig('cal_day_end'), 0, 0); } $obj->event_end_date = $seldate->format(FMT_TIMESTAMP); } $recurs = array('Never', 'Hourly', 'Daily', 'Weekly', 'Bi-Weekly', 'Monthly', 'Quarterly', 'Semi-Annually', 'Annually'); $remind = array('900' => '15 mins', '1800' => '30 mins', '3600' => '1 hour', '7200' => '2 hours', '14400' => '4 hours', '28800' => '8 hours', '56600' => '16 hours', '86400' => '1 day', '172800' => '2 days'); // build array of times in preference specified minute increments (default 30) $times = array(); $t = new CDate(); $t->setTime(0, 0, 0); //$m clashes with global $m (module) $check = 24 * 60 / $inc; $addMins = $inc * 60; for ($minutes = 0; $minutes < $check; $minutes++) { $times[$t->format('%H%M%S')] = $t->format($AppUI->getPref('TIMEFORMAT')); $t->addSeconds($addMins); } ?> <script type="text/javascript" language="javascript"> function submitIt() { var form = document.editFrm; if (form.event_title.value.length < 1) { alert('<?php echo $AppUI->_('Please enter a valid event title', UI_OUTPUT_JS);
$cal = new CMonthCalendar(); $html .= $cal->_drawBirthdays($this_day->format('%Y%m%d')); $html .= '<table cellspacing="1" cellpadding="2" border="0" width="100%" class="tbl">'; $this_day->setTime($start, 0, 0); for ($i = 0, $n = ($end - $start) * 60 / $inc; $i < $n; $i++) { $html .= "\n<tr>"; $tm = $this_day->format($tf); $html .= "\n\t" . '<td width="1%" align="right" nowrap="nowrap">' . ($this_day->getMinute() ? $tm : '<b>' . $tm . '</b>') . '</td>'; $timeStamp = $this_day->format('%H%M%S'); if (@$events2[$timeStamp]) { $count = count($events2[$timeStamp]); for ($j = 0; $j < $count; $j++) { $row = $events2[$timeStamp][$j]; $et = new CDate($row['event_end_date']); $et_date = new CDate($row['event_end_date']); $et_date->setTime(0, 0, 0); if ($et_date->after($this_day)) { $rows = $n - $i; } else { $rows = ($et->getHour() * 60 + $et->getMinute() - ($this_day->getHour() * 60 + $this_day->getMinute())) / $inc; } $href = "?m=calendar&a=view&event_id=" . $row['event_id']; $alt = $row['event_description']; $html .= "\n\t" . '<td class="event" rowspan="' . $rows . '" valign="top">'; $html .= "\n" . '<table cellspacing="0" cellpadding="0" border="0"><tr>'; $html .= "\n<td>" . dPshowImage(dPfindImage('event' . $row['event_type'] . '.png', 'calendar'), 16, 16, ''); $html .= "</td>\n<td> <b>" . $AppUI->_($types[$row['event_type']]) . '</b></td></tr></table>'; $html .= $href ? "\n\t\t" . '<a href="' . htmlspecialchars($href) . '" class="event" title="' . htmlspecialchars($alt) . '">' : ''; $html .= "\n\t\t" . htmlspecialchars($row['event_title']); $html .= $href ? "\n\t\t</a>" : ''; $html .= "\n\t</td>";
function clash_process() { global $AppUI, $do_include; $obj =& new CEvent(); $obj->bind($_SESSION['add_event_post']); $attendees = $_SESSION['add_event_attendees']; $users = array(); if (isset($attendees) && $attendees) { $users = explode(',', $attendees); } array_push($users, $obj->event_owner); // First remove any duplicates $users = array_unique($users); // Now remove any null entries, so implode doesn't create a dud SQL // Foreach is safer as it works on a copy of the array. foreach ($users as $key => $user) { if (!$user) { unset($users[$key]); } } // First find any events in the range requested. $start_date = new CDate($_POST['event_start_date'] . $_POST['start_time']); $end_date = new CDate($_POST['event_start_date'] . $_POST['start_time']); $end_date->addSeconds($_POST['duration'] * 60); $final_date = new CDate($_POST['event_end_date'] . $_POST['end_time']); $original_event_start = $obj->event_start_date; $original_event_end = $obj->event_end_date; $user_list = implode(',', $users); // Now we grab the events, in date order, and compare against the // required start and end times. // Working in 30 minute increments from the start time, and remembering // the end time stipulation, find the first hole in the times. // Determine the duration in hours/minutes. $start_hour = (int) ($_POST['start_time'] / 10000); $start_minutes = (int) ($_POST['start_time'] % 10000 / 100); $start_min_offset = $start_hour * 60 + $start_minutes; $end_hour = (int) ($_POST['end_time'] / 10000); $end_minutes = (int) ($_POST['end_time'] % 10000 / 100); $end_min_offset = $end_hour * 60 + $end_minutes - $_POST['duration']; // First, build a set of "slots" that give us the duration // and start/end times we need $first_day = $start_date->format('%E'); $end_day = $final_date->format('%E'); $oneday =& new Date_Span(array(1, 0, 0, 0)); $slots = array(); $curr_date = new CDate($start_date); $curr_date->setTime(0, 0, 0); $inc = intval(dPgetConfig('cal_day_increment')) ? intval(dPgetConfig('cal_day_increment')) : 30; for ($i = 0; $i <= $end_day - $first_day; $i++) { if ($curr_date->isWorkingDay()) { for ($j = $start_min_offset; $j <= $end_min_offset; $j += $inc) { $is_committed = false; $slot_start_date = new CDate($curr_date); $slot_start_date->addSeconds($j * 60); $slot_end_date = new CDate($slot_start_date); $slot_end_date->addSeconds($_POST['duration'] * 60); $obj->event_start_date = $slot_start_date->format('%Y-%m-%d %T'); $obj->event_end_date = $slot_end_date->format('%Y-%m-%d %T'); if (!($clash = $obj->checkClash($user_list))) { $_SESSION['add_event_post'] = get_object_vars($obj); $AppUI->setMsg('First available time slot', UI_MSG_OK); $_SESSION['event_is_clash'] = true; $_GET['event_id'] = $obj->event_id; $do_include = DP_BASE_DIR . '/modules/calendar/addedit.php'; return; } } } $curr_date->addSpan($oneday); $curr_date->setTime(0, 0, 0); } // If we get here we have found no available slots $obj->event_start_date = $original_event_start; $obj->event_end_date = $original_event_end; clear_clash(); $AppUI->setMsg('No times match your parameters', UI_MSG_ALERT); $AppUI->redirect(); }
function clash_suggest() { global $AppUI, $dPconfig; $obj =& new CEvent(); $obj->bind($_SESSION['add_event_post']); $start_date =& new CDate($obj->event_start_date); $end_date =& new CDate($obj->event_end_date); $df = $AppUI->getPref('SHDATEFORMAT'); $start_secs = $start_date->getTime(); $end_secs = $end_date->getTime(); $duration = (int) (($end_secs - $start_secs) / 60); $titleBlock =& new CTitleBlock("Suggest Alternative Event Time"); $titleBlock->show(); $calurl = $dPconfig['base_url'] . "/index.php?m=calendar&a=clash&event_id=" . $obj->event_id; $times = array(); $t = new CDate(); $t->setTime(0, 0, 0); if (!defined('LOCALE_TIME_FORMAT')) { define('LOCALE_TIME_FORMAT', '%I:%M %p'); } for ($m = 0; $m < 60; $m++) { $times[$t->format("%H%M%S")] = $t->format(LOCALE_TIME_FORMAT); $t->addSeconds(1800); } ?> <script language="javascript"> function set_clash_action(action) { document.editFrm.clash_action.value = action; document.editFrm.submit(); } Calendar.enabled = true; </script> <form name='editFrm' method='POST' action='<?php echo "{$calurl}&clash_action=process"; ?> '> <table width='100%' class='std'> <tr> <td width='50%' align='right'><?php echo $AppUI->_('Earliest Date'); ?> :</td> <td width='50%' align='left' nowrap="nowrap"> <input id="idDateStart" type="hidden" name="event_start_date" value="<?php echo $start_date->format(FMT_TIMESTAMP_DATE); ?> "> <input id="idDateStartD" type="text" name="start_date" value="<?php echo $start_date->format($df); ?> " class="text" disabled="disabled"> <img id="idDateStartB" src="images/calendar.gif" width="24" height="12" alt="<?php echo $AppUI->_('Calendar'); ?> " border="0" /> </td> </tr> <tr> <td width='50%' align='right'><?php echo $AppUI->_('Latest Date'); ?> :</td> <td width='50%' align='left' nowrap="nowrap"> <input id="idDateEnd" type="hidden" name="event_end_date" value="<?php echo $end_date->format(FMT_TIMESTAMP_DATE); ?> "> <input id="idDateEndD" type="text" name="end_date" value="<?php echo $end_date->format($df); ?> " class="text" disabled="disabled"> <img id="idDateEndB" src="images/calendar.gif" width="24" height="12" alt="<?php echo $AppUI->_('Calendar'); ?> " border="0" /> </td> </tr> <tr> <td width='50%' align='right'><?php echo $AppUI->_('Earliest Start Time'); ?> :</td> <td width='50%' align='left'> <?php echo arraySelect($times, 'start_time', 'size="1" class="text"', $start_date->format("%H%M%S")); ?> </td> </tr> <tr> <td width='50%' align='right'><?php echo $AppUI->_('Latest Finish Time'); ?> :</td> <td width='50%' align='left'> <?php echo arraySelect($times, 'end_time', 'size="1" class="text"', $end_date->format("%H%M%S")); ?> </td> </tr> <tr> <td width='50%' align='right'><?php echo $AppUI->_('Duration'); ?> :</td> <td width='50%' align='left'> <input type="text" class="text" size=5 name="duration" value="<?php echo $duration; ?> "> <?php echo $AppUI->_('minutes'); ?> </td> </tr> <tr> <td><input type="button" value="<?php echo $AppUI->_('cancel'); ?> " class="button" onClick="set_clash_action('cancel');" /></td> <td align="right"><input type="button" value="<?php echo $AppUI->_('save'); ?> " class="button" onClick="set_clash_action('process')" /></td> </tr> </table> <input type='hidden' name='clash_action' value='cancel'> </form> <?php }
public function store(CAppUI $AppUI = null) { global $AppUI; $perms = $AppUI->acl(); $stored = false; $this->w2PTrimAll(); $this->project_target_budget = str_replace(',', '', $this->project_target_budget); // ensure changes of state in checkboxes is captured $this->project_active = (int) $this->project_active; $this->project_private = (int) $this->project_private; $this->project_target_budget = $this->project_target_budget ? $this->project_target_budget : 0.0; $this->project_actual_budget = $this->project_actual_budget ? $this->project_actual_budget : 0.0; // Make sure project_short_name is the right size (issue for languages with encoded characters) if (mb_strlen($this->project_short_name) > 10) { $this->project_short_name = mb_substr($this->project_short_name, 0, 10); } if (empty($this->project_end_date)) { $this->project_end_date = null; } $errorMsgArray = $this->check(); if (count($errorMsgArray) > 0) { return $errorMsgArray; } $this->project_id = (int) $this->project_id; // convert dates to SQL format first if ($this->project_start_date) { $date = new CDate($this->project_start_date); $this->project_start_date = $date->format(FMT_DATETIME_MYSQL); } if ($this->project_end_date) { $date = new CDate($this->project_end_date); $date->setTime(23, 59, 59); $this->project_end_date = $date->format(FMT_DATETIME_MYSQL); } if ($this->project_actual_end_date) { $date = new CDate($this->project_actual_end_date); $this->project_actual_end_date = $date->format(FMT_DATETIME_MYSQL); } // let's check if there are some assigned departments to project if ('' != $this->project_actual_end_date) { $obj->project_departments = implode(',', w2PgetParam($_POST, 'dept_ids', array())); } // check project parents and reset them to self if they do not exist if (!$this->project_parent) { $this->project_parent = $this->project_id; $this->project_original_parent = $this->project_id; } else { $parent_project = new CProject(); $parent_project->load($this->project_parent); $this->project_original_parent = $parent_project->project_original_parent; } if (!$this->project_original_parent) { $this->project_original_parent = $this->project_id; } /* * TODO: I don't like the duplication on each of these two branches, but I * don't have a good idea on how to fix it at the moment... */ if ($this->project_id && $perms->checkModuleItem('projects', 'edit', $this->company_id)) { $q = new DBQuery(); $this->project_updated = $q->dbfnNow(); if ($msg = parent::store()) { return $msg; } addHistory('projects', $this->project_id, 'update', $this->project_name, $this->project_id); $stored = true; } if (0 == $this->project_id && $perms->checkModuleItem('projects', 'add')) { $q = new DBQuery(); $this->project_updated = $q->dbfnNow(); $this->project_created = $q->dbfnNow(); if ($msg = parent::store()) { return $msg; } if (0 == $this->project_parent || 0 == $this->project_original_parent) { $this->project_parent = $this->project_id; $this->project_original_parent = $this->project_id; if ($msg = parent::store()) { return $msg; } } addHistory('projects', $this->project_id, 'add', $this->project_name, $this->project_id); $stored = true; } //split out related departments and store them seperatly. $q = new DBQuery(); $q->setDelete('project_departments'); $q->addWhere('project_id=' . (int) $this->project_id); $q->exec(); $q->clear(); if ($this->project_departments) { $departments = explode(',', $this->project_departments); foreach ($departments as $department) { $q->addTable('project_departments'); $q->addInsert('project_id', $this->project_id); $q->addInsert('department_id', $department); $q->exec(); $q->clear(); } } //split out related contacts and store them seperatly. $q->setDelete('project_contacts'); $q->addWhere('project_id=' . (int) $this->project_id); $q->exec(); $q->clear(); if ($this->project_contacts) { $contacts = explode(',', $this->project_contacts); foreach ($contacts as $contact) { if ($contact) { $q->addTable('project_contacts'); $q->addInsert('project_id', $this->project_id); $q->addInsert('contact_id', $contact); $q->exec(); $q->clear(); } } } if ($stored) { $custom_fields = new CustomFields('projects', 'addedit', $this->project_id, 'edit'); $custom_fields->bind($_POST); $sql = $custom_fields->store($this->project_id); // Store Custom Fields } return $stored; }
function clash_suggest() { global $AppUI, $m, $a; $obj = new CEvent(); $obj->bind($_SESSION['add_event_post']); $start_date = new CDate($obj->event_start_date); $end_date = new CDate($obj->event_end_date); $df = $AppUI->getPref('SHDATEFORMAT'); $start_secs = $start_date->getTime(); $end_secs = $end_date->getTime(); $duration = (int) (($end_secs - $start_secs) / 60); $titleBlock = new CTitleBlock('Suggest Alternative Event Time', 'myevo-appointments.png', $m, $m . '.' . $a); $titleBlock->show(); $calurl = W2P_BASE_URL . '/index.php?m=calendar&a=clash&event_id=' . $obj->event_id; $times = array(); $t = new CDate(); $t->setTime(0, 0, 0); if (!defined('LOCALE_TIME_FORMAT')) { define('LOCALE_TIME_FORMAT', '%I:%M %p'); } for ($m = 0; $m < 60; $m++) { $times[$t->format('%H%M%S')] = $t->format(LOCALE_TIME_FORMAT); $t->addSeconds(1800); } ?> <script language="javascript"> function setDate( frm_name, f_date ) { fld_date = eval( 'document.' + frm_name + '.' + f_date ); fld_real_date = eval( 'document.' + frm_name + '.' + 'event_' + f_date ); if (fld_date.value.length>0) { if ((parseDate(fld_date.value))==null) { alert('The Date/Time you typed does not match your prefered format, please retype.'); fld_real_date.value = ''; fld_date.style.backgroundColor = 'red'; } else { fld_real_date.value = formatDate(parseDate(fld_date.value), 'yyyyMMdd'); fld_date.value = formatDate(parseDate(fld_date.value), '<?php echo $cal_sdf; ?> '); fld_date.style.backgroundColor = ''; } } else { fld_real_date.value = ''; } } function set_clash_action(action) { document.editFrm.clash_action.value = action; document.editFrm.submit(); } </script> <form name="editFrm" method="POST" action="<?php echo $calurl . '&clash_action=process'; ?> " accept-charset="utf-8"> <table width='100%' class='std'> <tr> <td width='50%' align='right'><?php echo $AppUI->_('Earliest Date'); ?> :</td> <td width='50%' align='left' nowrap="nowrap"> <input type="hidden" name="event_start_date" id="event_start_date" value="<?php echo $start_date ? $start_date->format(FMT_TIMESTAMP_DATE) : ''; ?> " /> <input type="text" name="start_date" id="start_date" onchange="setDate('editFrm', 'start_date');" value="<?php echo $start_date ? $start_date->format($df) : ''; ?> " class="text" /> <a href="javascript: void(0);" onclick="return showCalendar('start_date', '<?php echo $df; ?> ', 'editFrm', null, true)"> <img src="<?php echo w2PfindImage('calendar.gif'); ?> " width="24" height="12" alt="<?php echo $AppUI->_('Calendar'); ?> " border="0" /> </a> </td> </tr> <tr> <td width='50%' align='right'><?php echo $AppUI->_('Latest Date'); ?> :</td> <td width='50%' align='left' nowrap="nowrap"> <input type="hidden" name="event_end_date" id="event_end_date" value="<?php echo $end_date ? $end_date->format(FMT_TIMESTAMP_DATE) : ''; ?> " /> <input type="text" name="end_date" id="end_date" onchange="setDate('editFrm', 'end_date');" value="<?php echo $end_date ? $end_date->format($df) : ''; ?> " class="text" /> <a href="javascript: void(0);" onclick="return showCalendar('end_date', '<?php echo $df; ?> ', 'editFrm', null, true)"> <img src="<?php echo w2PfindImage('calendar.gif'); ?> " width="24" height="12" alt="<?php echo $AppUI->_('Calendar'); ?> " border="0" /> </a> </td> </tr> <tr> <td width='50%' align='right'><?php echo $AppUI->_('Earliest Start Time'); ?> :</td> <td width='50%' align='left'> <?php echo arraySelect($times, 'start_time', 'size="1" class="text"', $start_date->format('%H%M%S')); ?> </td> </tr> <tr> <td width='50%' align='right'><?php echo $AppUI->_('Latest Finish Time'); ?> :</td> <td width='50%' align='left'> <?php echo arraySelect($times, 'end_time', 'size="1" class="text"', $end_date->format('%H%M%S')); ?> </td> </tr> <tr> <td width='50%' align='right'><?php echo $AppUI->_('Duration'); ?> :</td> <td width='50%' align='left'> <input type="text" class="text" size="5" name="duration" value="<?php echo $duration; ?> " /> <?php echo $AppUI->_('minutes'); ?> </td> </tr> <tr> <td><input type="button" value="<?php echo $AppUI->_('cancel'); ?> " class="button" onclick="set_clash_action('cancel');" /></td> <td align="right"><input type="button" value="<?php echo $AppUI->_('submit'); ?> " class="button" onclick="set_clash_action('process')" /></td> </tr> </table> <input type='hidden' name='clash_action' value='cancel' /> </form> <?php }