$q->addWhere('project_id = ' . $project_id); $result =& $q->exec(); $start_date = new CDate($result->fields['project_start_date']); $end_date = new CDate($result->fields['project_end_date']); $current_date = new CDate(); $q->clear(); $q->addTable('projects_statistics', 'ps'); $q->addQuery('project_statistics_timestamp, project_statistics_project_id, ' . 'project_statistics_project_finish_date, project_statistics_percent_complete,' . 'project_statistics_tasks_total, project_statistics_tasks_complete, ' . 'project_statistics_helpdesk_total, project_statistics_helpdesk_total_closed,' . 'project_statistics_helpdesk_bugs, project_statistics_helpdesk_features, ' . 'project_statistics_helpdesk_suggestions, project_statistics_helpdesk_issues, ' . 'project_statistics_helpdesk_bugs_closed, project_statistics_helpdesk_features_closed, ' . 'project_statistics_helpdesk_suggestions_closed, project_statistics_helpdesk_issues_closed,' . 'project_statistics_helpdesk_bugs_testing, project_statistics_helpdesk_features_testing,' . 'project_statistics_helpdesk_suggestions_testing, project_statistics_helpdesk_issues_testing'); $q->addWhere('project_statistics_project_id = ' . $project_id); $result =& $q->exec(); $xdata = array(); $ydata = array(); $i = 0; foreach ($result as $item) { $date = new CDate($item['project_statistics_timestamp']); $xdata[$i] = $date->getTime(); $ydata[$i] = $item['project_statistics_percent_complete']; $i++; } // reference plot $ref_y = array(1, 100); $ref_x = array($start_date->getTime(), $end_date->getTime()); // --------------------------------------------------------------------------- // Width and height of the graph $width = 800; $height = 300; // Create a graph instance $graph = new Graph($width, $height); $graph->img->SetImgFormat('jpeg'); $graph->SetMargin(40, 10, 10, 100); // Specify what scale we want to use,
\', \'editFrm\', \'<?php echo strpos($cf, '%p') !== false ? '12' : '24'; ?> \', true)" >'; htmltxt +=' <img src="<?php echo w2PfindImage('calendar.gif', $m); ?> " width="24" height="12" border="0" />'; htmltxt +='</a>'; oCell.innerHTML =htmltxt; newtr.appendChild(oCell); oCell = document.createElement('td'); htmltxt = ''; // htmltxt +='<input type='hidden' id='add_task_duration_'+line_nr+'' name='add_task_duration_'+line_nr+'' value='' />'; htmltxt +='<input type="hidden" id="add_task_end_date_'+line_nr+'" name="add_task_end_date_'+line_nr+'" value="<?php $today->setDate($today->getTime() + 60 * 60, DATE_FORMAT_UNIXTIME); echo $today->format(FMT_TIMESTAMP); ?> " />'; htmltxt +='<input type="text" onchange="setDate(\'editFrm\', \'end_date_'+line_nr+'\');" class="text" style="width:130px;" id="end_date_'+line_nr+'" name="end_date_'+line_nr+'" value="<?php echo $today->format($cf); ?> " />'; htmltxt +='<a href="javascript: void(0);" onclick="return showCalendar(\'end_date_'+line_nr+'\', \'<?php echo $cf; ?> \', \'editFrm\', \'<?php echo strpos($cf, '%p') !== false ? '12' : '24'; ?> \', true)" >'; htmltxt +=' <img src="<?php
/** Import tasks from another project * * @param int Project ID of the tasks come from. * @return bool **/ function importTasks($from_project_id) { // 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)); $origDate = new CDate($origProject->project_start_date); $destDate = new CDate($this->project_start_date); $timeOffset = $destDate->getTime() - $origDate->getTime(); // Dependencies array $deps = array(); // Copy each task into this project and get their deps foreach ($tasks as $orig => $void) { $objTask = new CTask(); $objTask->load($orig); $destTask = $objTask->copy($this->project_id); $tasks[$orig] = $destTask; $deps[$orig] = $objTask->getDependencies(); } // Fix record integrity foreach ($tasks as $old_id => $newTask) { // Fix parent Task // This task had a parent task, adjust it to new parent task_id if ($newTask->task_id != $newTask->task_parent) { $newTask->task_parent = $tasks[$newTask->task_parent]->task_id; } // Fix task start date from project start date offset $origDate->setDate($newTask->task_start_date); $destDate->setDate($origDate->getTime() + $timeOffset, DATE_FORMAT_UNIXTIME); $destDate = $destDate->next_working_day(); $newTask->task_start_date = $destDate->format(FMT_DATETIME_MYSQL); // Fix task end date from start date + work duration //$newTask->calc_task_end_date(); if (!empty($newTask->task_end_date) && $newTask->task_end_date != '0000-00-00 00:00:00') { $origDate->setDate($newTask->task_end_date); $destDate->setDate($origDate->getTime() + $timeOffset, DATE_FORMAT_UNIXTIME); $destDate = $destDate->next_working_day(); $newTask->task_end_date = $destDate->format(FMT_DATETIME_MYSQL); } // Dependencies if (!empty($deps[$old_id])) { $oldDeps = explode(',', $deps[$old_id]); // New dependencies array $newDeps = array(); foreach ($oldDeps as $dep) { $newDeps[] = $tasks[$dep]->task_id; } // Update the new task dependencies $csList = implode(',', $newDeps); $newTask->updateDependencies($csList); } // end of update dependencies $newTask->store(); } // end Fix record integrity }
/** Import tasks from another project * * @param int Project ID of the tasks come from. * @return bool **/ function importTasks($from_project_id) { // 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)); $origDate = new CDate($origProject->project_start_date); $destDate = new CDate($this->project_start_date); $timeOffset = $destDate->getTime() - $origDate->getTime(); $objTask = new CTask(); // Dependencies array $deps = array(); // Copy each task into this project and get their deps, y tambien copia los usuarios asignados foreach ($tasks as $orig => $void) { $objTask->load($orig); $destTask = $objTask->copy($this->project_id); $tasks[$orig] = $destTask; if ($this->project_company == $origProject->project_company) { // guarda en user_tasks todos los usuarios asignados a la tarea original, solo si this y // origProy pertenecen a la misma compañía. $sql = "select * from user_tasks where task_id = {$orig}"; $rows = db_LoadList($sql); foreach ($rows as $row) { $sql2 = "INSERT INTO user_tasks (user_id, user_type, task_id, perc_assignment, user_task_priority) \n\t\t\t\t\t\t\t\tVALUES (" . $row['user_id'] . "," . $row['user_type'] . "," . $destTask->task_id . "," . $row['perc_assignment'] . "," . $row['user_task_priority'] . ")"; db_exec($sql2); } } $deps[$orig] = $objTask->getDependencies(); } // Fix record integrity foreach ($tasks as $old_id => $newTask) { // Fix parent Task // This task had a parent task, adjust it to new parent task_id if ($newTask->task_id != $newTask->task_parent) { $newTask->task_parent = $tasks[$newTask->task_parent]->task_id; } // Fix task start date from project start date offset $origDate->setDate($newTask->task_start_date); $destDate->setDate($origDate->getTime() + $timeOffset, DATE_FORMAT_UNIXTIME); $destDate = $newTask->next_working_day($destDate); $newTask->task_start_date = $destDate->format(FMT_DATETIME_MYSQL); // Fix task end date from start date + work duration $newTask->calc_task_end_date(); // Dependencies if (!empty($deps[$old_id])) { $oldDeps = explode(',', $deps[$old_id]); // New dependencies array $newDeps = array(); foreach ($oldDeps as $dep) { $newDeps[] = $tasks[$dep]->task_id; } // Update the new task dependencies $csList = implode(',', $newDeps); $newTask->updateDependencies($csList); } // end of update dependencies //Asignados $newTask->store(); } // end Fix record integrity }
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; $inc = intval(dPgetConfig('cal_day_increment')) ? intval(dPgetConfig('cal_day_increment')) : 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"> var calendarField = ''; function popCalendar(field) { calendarField = field; idate = eval('document.editFrm.event_' + field + '.value'); window.open('?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="javascript: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="javascript: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="javascript:set_clash_action('cancel');" /></td> <td align="right"><input type="button" value="<?php echo $AppUI->_('submit'); ?> " class="button" onclick="javascript:set_clash_action('process')" /></td> </tr> </table> <input type='hidden' name='clash_action' value='cancel'> </form> <?php }
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 }
/** Import tasks from another project * * @param int Project ID of the tasks come from. * @return bool **/ function importTasks($from_project_id) { // 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); $q->addWhere('task_id = task_parent'); $sql = $q->prepare(); $q->clear(); $tasks = array_flip(db_loadColumn($sql)); $origDate = new CDate($origProject->project_start_date); $destDate = new CDate($this->project_start_date); $timeOffset = $destDate->getTime() - $origDate->getTime(); // Dependencies array $deps = array(); // Copy each task into this project and get their deps foreach ($tasks as $orig => $void) { $objTask = new CTask(); $objTask->load($orig); $destTask = $objTask->deepCopy($this->project_id); $tasks[$orig] = $destTask; $deps[$orig] = $objTask->getDependencies(); } $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. $newTask = new CTask(); foreach ($tasks as $task_id) { $newTask->load($task_id); // Fix task start date from project start date offset $origDate->setDate($newTask->task_start_date); $destDate->setDate($origDate->getTime() + $timeOffset, DATE_FORMAT_UNIXTIME); $destDate = $destDate->next_working_day(); $newTask->task_start_date = $destDate->format(FMT_DATETIME_MYSQL); // Fix task end date from start date + work duration //$newTask->calc_task_end_date(); if (!empty($newTask->task_end_date) && $newTask->task_end_date != '0000-00-00 00:00:00') { $origDate->setDate($newTask->task_end_date); $destDate->setDate($origDate->getTime() + $timeOffset, DATE_FORMAT_UNIXTIME); $destDate = $destDate->next_working_day(); $newTask->task_end_date = $destDate->format(FMT_DATETIME_MYSQL); } $newTask->store(); } // end Fix record integrity }