Exemple #1
0
 function store()
 {
     $msg = $this->check();
     if ($msg) {
         return get_class($this) . "::store-check failed";
     }
     $q = new DBQuery();
     if ($this->user_id) {
         // save the old password
         $perm_func = "updateLogin";
         $q->addTable('users');
         $q->addQuery('user_password');
         $q->addWhere("user_id = {$this->user_id}");
         $pwd = $q->loadResult();
         if ($pwd != $this->user_password) {
             $this->user_password = md5($this->user_password);
         } else {
             $this->user_password = null;
         }
         $ret = db_updateObject('users', $this, 'user_id', false);
     } else {
         $perm_func = "addLogin";
         $this->user_password = md5($this->user_password);
         $ret = db_insertObject('users', $this, 'user_id');
     }
     if (!$ret) {
         return get_class($this) . "::store failed <br />" . db_error();
     } else {
         $acl =& $GLOBALS['AppUI']->acl();
         $acl->{$perm_func}($this->user_id, $this->user_username);
         //Insert Default Preferences
         //Lets check if the user has allready default users preferences set, if not insert the default ones
         $q->addTable('user_preferences', 'upr');
         $q->addWhere("upr.pref_user = {$this->user_id}");
         $uprefs = $q->loadList();
         $q->clear();
         if (!count($uprefs) && $this->user_id > 0) {
             //Lets get the default users preferences
             $q->addTable('user_preferences', 'dup');
             $q->addWhere("dup.pref_user = 0");
             $dprefs = $q->loadList();
             $q->clear();
             foreach ($dprefs as $dprefskey => $dprefsvalue) {
                 $q->addTable('user_preferences', 'up');
                 $q->addInsert('pref_user', $this->user_id);
                 $q->addInsert('pref_name', $dprefsvalue['pref_name']);
                 $q->addInsert('pref_value', $dprefsvalue['pref_value']);
                 $q->exec();
                 $q->clear();
             }
         }
         return NULL;
     }
 }
/** Retrieve tasks with first task_end_dates within given project
 * @param int Project_id
 * @param int SQL-limit to limit the number of returned tasks
 * @return array List of criticalTasks
 */
function getCriticalTasksInverted($project_id = null, $limit = 1)
{
    if (!$project_id) {
        $result = array();
        $result[0]['task_end_date'] = '0000-00-00 00:00:00';
        return $result;
    } else {
        $q = new DBQuery();
        $q->addTable('tasks');
        $q->addWhere('task_project = ' . (int) $project_id . ' AND NOT ISNULL( task_end_date ) AND task_end_date <>  \'0000-00-00 00:00:00\'');
        $q->addOrder('task_start_date ASC');
        $q->setLimit($limit);
        return $q->loadList();
    }
}
/** Retrieve tasks with first task_end_dates within given project
* @param int Project_id
* @param int SQL-limit to limit the number of returned tasks
* @return array List of criticalTasks
*/
function getCriticalTasksInverted($project_id = NULL, $limit = 1)
{
    if (!$project_id) {
        $result = array();
        $result[0]['task_end_date'] = '0000-00-00 00:00:00';
        return $result;
    } else {
        $q = new DBQuery();
        $q->addTable('tasks');
        $q->addWhere("task_project = {$project_id} AND !isnull( task_end_date ) AND task_end_date !=  '0000-00-00 00:00:00'");
        $q->addOrder('task_start_date ASC');
        $q->setLimit($limit);
        return $q->loadList();
    }
}
Exemple #4
0
    }
    // show tasks which are both finished and past in (dark)gray
    if ($progress >= 100 && $end_date->isPast() && get_class($bar) == 'ganttbar') {
        $bar->caption->SetColor('darkgray');
        $bar->title->SetColor('darkgray');
        $bar->setColor('darkgray');
        $bar->SetFillColor('darkgray');
        $bar->SetPattern(BAND_SOLID, 'gray');
        $bar->progress->SetFillColor('darkgray');
        $bar->progress->SetPattern(BAND_SOLID, 'gray', 98);
    }
    $q = new DBQuery();
    $q->addTable('task_dependencies');
    $q->addQuery('dependencies_task_id');
    $q->addWhere('dependencies_req_task_id=' . (int) $a['task_id']);
    $query = $q->loadList();
    foreach ($query as $dep) {
        // find row num of dependencies
        for ($d = 0, $d_cmp = count($gantt_arr); $d < $d_cmp; $d++) {
            if ($gantt_arr[$d][0]['task_id'] == $dep['dependencies_task_id']) {
                $bar->SetConstrain($d, CONSTRAIN_ENDSTART);
            }
        }
    }
    unset($query);
    $q->clear();
    $graph->Add($bar);
}
unset($gantt_arr);
$today = new CDate();
$vline = new GanttVLine($today->format(FMT_TIMESTAMP_DATE), $AppUI->_('Today', UI_OUTPUT_RAW));
Exemple #5
0
$q->leftJoin('project_departments', 'project_departments', 'projects.project_id = project_departments.project_id OR project_departments.project_id IS NULL');
$q->leftJoin('departments', 'departments', 'departments.dept_id = project_departments.department_id OR dept_id IS NULL');
$q->addWhere('task_project = ' . (int) $project_id);
$allowedProjects = $project->getAllowedSQL($AppUI->user_id, 'task_project');
if (count($allowedProjects)) {
    $q->addWhere($allowedProjects);
}
$obj = new CTask();
$allowedTasks = $obj->getAllowedSQL($AppUI->user_id, 'tasks.task_id');
if (count($allowedTasks)) {
    $q->addWhere($allowedTasks);
}
$q->addGroup('tasks.task_id');
$q->addOrder('task_start_date');
if ($canViewTasks) {
    $tasks = $q->loadList();
}
// POST PROCESSING TASKS
foreach ($tasks as $row) {
    //add information about assigned users into the page output
    $q->clear();
    $q->addQuery('ut.user_id,	u.user_username');
    $q->addQuery('contact_email, ut.perc_assignment, SUM(ut.perc_assignment) AS assign_extent');
    $q->addQuery('contact_first_name, contact_last_name');
    $q->addTable('user_tasks', 'ut');
    $q->leftJoin('users', 'u', 'u.user_id = ut.user_id');
    $q->leftJoin('contacts', 'c', 'u.user_contact = c.contact_id');
    $q->addWhere('ut.task_id = ' . (int) $row['task_id']);
    $q->addGroup('ut.user_id');
    $q->addOrder('perc_assignment desc, user_username');
    $assigned_users = array();
 function notify($comment = '')
 {
     $q = new DBQuery();
     global $AppUI, $locale_char_set;
     $df = $AppUI->getPref('SHDATEFORMAT');
     $df .= ' ' . $AppUI->getPref('TIMEFORMAT');
     $q->addTable("projects");
     $q->addQuery("project_name");
     $q->addWhere("project_id={$this->task_project}");
     $projname = htmlspecialchars_decode(db_loadResult($q->prepare(true)));
     $mail = new Mail();
     $mail->Subject($projname . '::' . $this->task_name . ' ' . $AppUI->_($this->_action, UI_OUTPUT_RAW), $locale_char_set);
     // c = creator
     // a = assignee
     // o = owner
     $q->addTable('tasks', 't');
     $q->leftJoin('user_tasks', 'ut', 'ut.task_id = t.task_id');
     $q->leftJoin('users', 'o', 'o.user_id = t.task_owner');
     $q->leftJoin('contacts', 'oc', 'oc.contact_id = o.user_contact');
     $q->leftJoin('users', 'c', 'c.user_id = t.task_creator');
     $q->leftJoin('contacts', 'cc', 'cc.contact_id = c.user_contact');
     $q->leftJoin('users', 'a', 'a.user_id = ut.user_id');
     $q->leftJoin('contacts', 'ac', 'ac.contact_id = a.user_contact');
     $q->addQuery('t.task_id, c.user_id as creator_id, cc.contact_email as creator_email' . ', cc.contact_first_name as creator_first_name' . ', cc.contact_last_name as creator_last_name' . ', o.user_id as owner_id, oc.contact_email as owner_email' . ', oc.contact_first_name as owner_first_name' . ', oc.contact_last_name as owner_last_name' . ', a.user_id as assignee_id, ac.contact_email as assignee_email' . ', ac.contact_first_name as assignee_first_name' . ', ac.contact_last_name as assignee_last_name');
     $q->addWhere(' t.task_id = ' . $this->task_id);
     $users = $q->loadList();
     if (count($users)) {
         $task_start_date = new CDate($this->task_start_date);
         $task_finish_date = new CDate($this->task_end_date);
         $priority = dPgetSysVal('TaskPriority');
         $body = $AppUI->_('Project', UI_OUTPUT_RAW) . ': ' . $projname . "\n" . $AppUI->_('Task', UI_OUTPUT_RAW) . ':	 ' . $this->task_name;
         $body .= "\n" . $AppUI->_('Priority') . ': ' . $priority[$this->task_priority];
         $body .= "\n" . $AppUI->_('Start Date', UI_OUTPUT_RAW) . ': ' . $task_start_date->format($df) . "\n" . $AppUI->_('Finish Date', UI_OUTPUT_RAW) . ': ' . ($this->task_end_date != '' ? $task_finish_date->format($df) : '') . "\n" . $AppUI->_('URL', UI_OUTPUT_RAW) . ': ' . DP_BASE_URL . '/index.php?m=tasks&a=view&task_id=' . $this->task_id . "\n\n" . $AppUI->_('Description', UI_OUTPUT_RAW) . ': ' . "\n" . $this->task_description;
         if ($users[0]['creator_email']) {
             $body .= "\n\n" . $AppUI->_('Creator', UI_OUTPUT_RAW) . ':' . "\n" . $users[0]['creator_first_name'] . ' ' . $users[0]['creator_last_name'] . ', ' . $users[0]['creator_email'];
         }
         $body .= "\n\n" . $AppUI->_('Owner', UI_OUTPUT_RAW) . ':' . "\n" . $users[0]['owner_first_name'] . ' ' . $users[0]['owner_last_name'] . ', ' . $users[0]['owner_email'];
         if ($comment != '') {
             $body .= "\n\n" . $comment;
         }
         $mail->Body($body, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : '');
         $mail->From('"' . $AppUI->user_first_name . ' ' . $AppUI->user_last_name . '" <' . $AppUI->user_email . '>');
         $owner_is_assigned = false;
         foreach ($users as $row) {
             if ($mail->ValidEmail($row['assignee_email'])) {
                 $mail->To($row['assignee_email'], true);
                 $mail->Send();
             }
             if ($row['assignee_id'] == $row['owner_id']) {
                 $owner_is_assigned = true;
             }
         }
         if ($AppUI->getPref('MAILALL') && !$owner_is_assigned) {
             $last_record = array_pop($users);
             $owner_email = $last_record['owner_email'];
             array_push($users, $last_record);
             if ($mail->ValidEmail($owner_email)) {
                 $mail->To($owner_email, true);
                 $mail->Send();
             }
         }
     }
     return '';
 }
function displayFiles($folder)
{
    global $m, $a, $tab, $AppUI, $xpg_min, $xpg_pagesize;
    global $deny1, $deny2, $project_id, $task_id, $showProject, $file_types, $cfObj;
    global $xpg_totalrecs, $xpg_total_pages, $page;
    global $company_id, $allowed_companies, $current_uri, $dPconfig;
    $canEdit = !getDenyEdit($m, $folder);
    $canRead = !getDenyRead($m, $folder);
    $df = $AppUI->getPref('SHDATEFORMAT');
    $tf = $AppUI->getPref('TIMEFORMAT');
    // SETUP FOR FILE LIST
    $q = new DBQuery();
    $q->addTable('files');
    $q->addQuery('files.*,count(file_version) as file_versions,round(max(file_version), 2) as file_lastversion,file_folder_id, file_folder_name,project_name, project_color_identifier,contact_first_name, contact_last_name,task_name,task_id');
    $q->addJoin('projects', 'p', 'p.project_id = file_project');
    $q->addJoin('users', 'u', 'u.user_id = file_owner');
    $q->addJoin('contacts', 'c', 'c.contact_id = u.user_contact');
    $q->addJoin('tasks', 't', 't.task_id = file_task');
    $q->addJoin('file_folders', 'ff', 'ff.file_folder_id = file_folder');
    $q->addWhere('file_folder = ' . $folder);
    if (count($deny1) > 0) {
        $q->addWhere('file_project NOT IN (' . implode(',', $deny1) . ')');
    }
    if (count($deny2) > 0) {
        $q->addWhere('file_task NOT IN (' . implode(',', $deny2) . ')');
    }
    if ($project_id) {
        $q->addWhere('file_project = ' . $project_id);
    }
    if ($task_id) {
        $q->addWhere('file_task = ' . $task_id);
    }
    if ($company_id) {
        $q->innerJoin('companies', 'co', 'co.company_id = p.project_company');
        $q->addWhere('company_id = ' . $company_id);
        $q->addWhere('company_id IN (' . $allowed_companies . ')');
    }
    $q->addGroup('file_folder');
    $q->addGroup('project_name');
    $q->addGroup('file_name');
    $q->addOrder('file_folder');
    $q->addOrder('project_name');
    $q->addOrder('file_name');
    $q->setLimit($xpg_pagesize, $xpg_min);
    $files_sql = $q->prepare();
    $q->clear();
    $q = new DBQuery();
    $q->addTable('files');
    $q->addQuery('files.file_id, file_version, file_project, file_name, file_task, file_description, user_username as file_owner, file_size, file_category, file_type, file_date, file_folder_name');
    $q->addJoin('projects', 'p', 'p.project_id = file_project');
    $q->addJoin('users', 'u', 'u.user_id = file_owner');
    $q->addJoin('tasks', 't', 't.task_id = file_task');
    $q->addJoin('file_folders', 'ff', 'ff.file_folder_id = file_folder');
    $q->addWhere('file_folder = ' . $folder);
    if ($project_id) {
        $q->addWhere('file_project = ' . $project_id);
    }
    if ($task_id) {
        $q->addWhere('file_task = ' . $task_id);
    }
    if ($company_id) {
        $q->innerJoin('companies', 'co', 'co.company_id = p.project_company');
        $q->addWhere('company_id = ' . $company_id);
        $q->addWhere('company_id IN (' . $allowed_companies . ')');
    }
    $file_versions_sql = $q->prepare();
    $q->clear();
    $files = array();
    $file_versions = array();
    if ($canRead) {
        $files = db_loadList($files_sql);
        $file_versions = db_loadList($file_versions_sql);
    }
    if ($files === array()) {
        return 0;
    }
    ?>
	<table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl">
	<tr>
		<th nowrap="nowrap"><?php 
    echo $AppUI->_('File Name');
    ?>
</th>
		<th><?php 
    echo $AppUI->_('Description');
    ?>
</th>
		<th><?php 
    echo $AppUI->_('Versions');
    ?>
</th>
	    <th><?php 
    echo $AppUI->_('Category');
    ?>
</th>
		<th nowrap="nowrap"><?php 
    echo $AppUI->_('Task Name');
    ?>
</th>
		<th><?php 
    echo $AppUI->_('Owner');
    ?>
</th>
		<th><?php 
    echo $AppUI->_('Size');
    ?>
</th>
		<th><?php 
    echo $AppUI->_('Type');
    ?>
</a></th>
		<th><?php 
    echo $AppUI->_('Date');
    ?>
</th>
    	<th nowrap="nowrap"><?php 
    echo $AppUI->_('co Reason');
    ?>
</th>
    	<th><?php 
    echo $AppUI->_('co');
    ?>
</th>
		<th nowrap width="1"></th>
		<th nowrap width="1"></th>
	</tr>
<?php 
    $fp = -1;
    $file_date = new CDate();
    $id = 0;
    foreach ($files as $row) {
        $file_date = new CDate($row['file_date']);
        if ($fp != $row["file_project"]) {
            if (!$row["project_name"]) {
                $row["project_name"] = $AppUI->_('All Projects');
                $row["project_color_identifier"] = 'f4efe3';
            }
            if ($showProject) {
                $s = '<tr>';
                $s .= '<td colspan="20" style="background-color:#' . $row["project_color_identifier"] . '">';
                $s .= '<font color="' . bestColor($row["project_color_identifier"]) . '">';
                if ($row['file_project'] > 0) {
                    $href = './index.php?m=projects&a=view&project_id=' . $row['file_project'];
                } else {
                    $href = './index.php?m=projects';
                }
                $s .= '<a href="' . $href . '">' . $row["project_name"] . '</a>';
                $s .= '</font></td></tr>';
                echo $s;
            }
        }
        $fp = $row["file_project"];
        if ($row['file_versions'] > 1) {
            $file = last_file($file_versions, $row['file_name'], $row['file_project']);
        } else {
            $file = $row;
        }
        ?>
	<form name="frm_remove_file_<?php 
        echo $file['file_id'];
        ?>
" action="?m=files" method="post">
	<input type="hidden" name="dosql" value="do_file_aed" />
	<input type="hidden" name="del" value="1" />
	<input type="hidden" name="file_id" value="<?php 
        echo $file['file_id'];
        ?>
" />
	<input type="hidden" name="redirect" value="<?php 
        echo $current_uri;
        ?>
" />
	</form>		
	<form name="frm_duplicate_file_<?php 
        echo $file['file_id'];
        ?>
" action="?m=files" method="post">
	<input type="hidden" name="dosql" value="do_file_aed" />
	<input type="hidden" name="duplicate" value="1" />
	<input type="hidden" name="file_id" value="<?php 
        echo $file['file_id'];
        ?>
" />
	<input type="hidden" name="redirect" value="<?php 
        echo $current_uri;
        ?>
" />
	</form>		
	<tr>
		<td nowrap="8%">
			<?php 
        $file_icon = getIcon($row['file_type']);
        echo "<a href=\"./fileviewer.php?file_id={$file['file_id']}\" title=\"{$file['file_description']}\"><img border=\"0\" width=\"16\" heigth=\"16\" src=\"" . DP_BASE_URL . "/modules/files/images/{$file_icon}\" />&nbsp;{$row['file_name']}</a>";
        ?>
		</td>
		<td width="20%"><?php 
        echo $file['file_description'];
        ?>
</td>
		<td width="5%" nowrap="nowrap" align="center">
	        <?php 
        $hidden_table = '';
        echo $row['file_lastversion'];
        if ($row['file_versions'] > 1) {
            echo ' <a href="#" onClick="expand(\'versions_' . $file['file_id'] . '\'); ">(' . $row['file_versions'] . ')</a>';
            $hidden_table = '<tr><td colspan="20">
	<table style="display: none" id="versions_' . $file['file_id'] . '" width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl">
	<tr>
	        <th nowrap="nowrap">' . $AppUI->_('File Name') . '</th>
	        <th>' . $AppUI->_('Description') . '</th>
	        <th>' . $AppUI->_('Versions') . '</th>
	        <th>' . $AppUI->_('Category') . '</th>
	        <th nowrap="nowrap">' . $AppUI->_('Task Name') . '</th>
	        <th>' . $AppUI->_('Owner') . '</th>
	        <th>' . $AppUI->_('Size') . '</th>
	        <th>' . $AppUI->_('Type') . '</a></th>
	        <th>' . $AppUI->_('Date') . '</th>
    		<th nowrap="nowrap">' . $AppUI->_('co Reason') . '</th>
    		<th>' . $AppUI->_('co') . '</th>
	        <th nowrap width="1"></th>
	        <th nowrap width="1"></th>
	</tr>
	';
            foreach ($file_versions as $file_row) {
                if ($file_row['file_name'] == $row['file_name'] && $file_row['file_project'] == $row['file_project']) {
                    $file_icon = getIcon($file_row['file_type']);
                    $file_date = new CDate($file_row['file_date']);
                    $hidden_table .= '	
			<form name="frm_delete_sub_file_' . $file_row['file_id'] . '" action="?m=files" method="post">
			<input type="hidden" name="dosql" value="do_file_aed" />
			<input type="hidden" name="del" value="1" />
			<input type="hidden" name="file_id" value="' . $file_row['file_id'] . '" />
			<input type="hidden" name="redirect" value="' . $current_uri . '" />
			</form>';
                    $hidden_table .= '	
			<form name="frm_duplicate_sub_file_' . $file_row['file_id'] . '" action="?m=files" method="post">
			<input type="hidden" name="dosql" value="do_file_aed" />
			<input type="hidden" name="duplicate" value="1" />
			<input type="hidden" name="file_id" value="' . $file_row['file_id'] . '" />
			<input type="hidden" name="redirect" value="' . $current_uri . '" />
			</form>';
                    $hidden_table .= '
	        <tr>
	                <td nowrap="8%"><a href="./fileviewer.php?file_id=' . $file_row['file_id'] . '" 
	                        title="' . $file_row['file_description'] . '">' . "<img border=\"0\" width=\"16\" heigth=\"16\" src=\"" . DP_BASE_URL . "/modules/files/images/{$file_icon}\" />&nbsp;" . $file_row['file_name'] . '
	                </a></td>
	                <td width="20%">' . $file_row['file_description'] . '</td>
	                <td width="5%" nowrap="nowrap" align="center">' . $file_row['file_version'] . '</td>
	                <td width="10%" nowrap="nowrap" align="center"><a href="./index.php?m=' . $m . '&a=' . $a . '&tab=' . ($file_row['file_category'] + 1) . '">' . $file_types[$file_row['file_category'] + 1] . '</a></td>
	                <td width="5%" align="center"><a href="./index.php?m=tasks&a=view&task_id=' . $file_row["file_task"] . '">' . $row["task_name"] . '</a></td>
	                <td width="15%" nowrap="nowrap">' . $row["contact_first_name"] . ' ' . $row["contact_last_name"] . '</td>
	                <td width="5%" nowrap="nowrap" align="right">' . intval($file_row['file_size'] / 1024) . 'kb </td>
	                <td width="15%" nowrap="nowrap">' . $file_row['file_type'] . '</td>
	                <td width="15%" nowrap="nowrap" align="right">' . $file_date->format("{$df} {$tf}") . '</td>
        			<td width="10%">' . $row['file_co_reason'] . '</td>
        			<td nowrap="nowrap" align="center">';
                    if ($canEdit && empty($file_row['file_checkout'])) {
                        $hidden_table .= '<a href="?m=files&a=co&file_id=' . $file_row['file_id'] . '">' . dPshowImage('./modules/files/images/up.png', '16', '16', 'checkout', 'checkout file') . '</a>';
                    } else {
                        if ($row['file_checkout'] == $AppUI->user_id) {
                            $hidden_table .= '<a href="?m=files&a=addedit&ci=1&file_id=' . $file_row['file_id'] . '">' . dPshowImage('./modules/files/images/down.png', '16', '16', 'checkin', 'checkin file') . '</a>';
                        } else {
                            if ($file_row['file_checkout'] == 'final') {
                                $hidden_table .= 'final';
                            } else {
                                $q4 = new DBQuery();
                                $q4->addQuery("file_id, file_checkout, user_username as co_user, contact_first_name, contact_last_name");
                                $q4->addTable('files');
                                $q4->leftJoin('users', 'cu', 'cu.user_id = file_checkout');
                                $q4->leftJoin('contacts', 'co', 'co.contact_id = cu.user_contact');
                                $q4->addWhere('file_id = ' . $file_row['file_id']);
                                $co_user = array();
                                $co_user = $q4->loadList();
                                $co_user = $co_user[0];
                                $q4->clear();
                                $hidden_table .= $co_user['contact_first_name'] . ' ' . $co_user['contact_last_name'] . '<br>(' . $co_user['co_user'] . ')';
                            }
                        }
                    }
                    $hidden_table .= '</td>';
                    $hidden_table .= '<td nowrap="nowrap" align="right" width="48">';
                    if ($canEdit && (empty($file_row['file_checkout']) || $file_row['file_checkout'] == 'final' && ($canEdit || $row['project_owner'] == $AppUI->user_id))) {
                        $hidden_table .= '<a href="./index.php?m=files&a=addedit&file_id=' . $file_row["file_id"] . '">' . dPshowImage('./modules/files/images/kedit.png', '16', '16', 'edit file', 'edit file') . "</a>" . '<a href="#" onclick="document.frm_duplicate_sub_file_' . $file_row['file_id'] . '.submit()">' . dPshowImage('./modules/files/images/duplicate.png', '16', '16', 'duplicate file', 'duplicate file') . "</a>" . '<a href="#" onclick="if (confirm(\'Are you sure you want to delete this file?\')) {document.frm_delete_sub_file_' . $file_row['file_id'] . '.submit()}">' . dPshowImage('./modules/files/images/remove.png', '16', '16', 'delete file', 'delete file') . "</a>";
                    }
                    $hidden_table .= '</td>';
                    $hidden_table .= '<td nowrap="nowrap" align="right" width="1">';
                    if ($canEdit && (empty($row['file_checkout']) || $row['file_checkout'] == 'final' && ($canEdit || $row['project_owner'] == $AppUI->user_id))) {
                        $bulk_op = 'onchange="(this.checked) ? addBulkComponent(' . $file_row['file_id'] . ') : removeBulkComponent(' . $file_row['file_id'] . ')"';
                        $hidden_table .= '<input type="checkbox" ' . $bulk_op . ' name="chk_sub_sel_file_' . $file_row['file_id'] . '" />';
                    }
                    $hidden_table .= '</td>';
                    $hidden_table .= '</tr>';
                }
            }
            $hidden_table .= '</table>';
            //$hidden_table .= '</span>';
        }
        ?>
	        </td>
	        <td width="10%" nowrap="nowrap" align="center"><a href="./index.php?m=<?php 
        echo $m;
        ?>
&a=<?php 
        echo $a;
        ?>
&view=categories&tab=<?php 
        echo $file['file_category'];
        ?>
"><?php 
        echo $file_types[$file["file_category"]];
        ?>
</a></td> 
		<td width="5%" align="center"><a href="./index.php?m=tasks&a=view&task_id=<?php 
        echo $file["task_id"];
        ?>
"><?php 
        echo $file["task_name"];
        ?>
</a></td>
		<td width="15%" nowrap="nowrap"><?php 
        echo $file["contact_first_name"] . ' ' . $file["contact_last_name"];
        ?>
</td>
		<td width="5%" nowrap="nowrap" align="right"><?php 
        echo intval($file["file_size"] / 1024);
        ?>
 kb</td>
		<td width="15%" nowrap="nowrap"><?php 
        echo $file["file_type"];
        ?>
</td>
		<td width="15%" nowrap="nowrap" align="right"><?php 
        echo $file_date->format("{$df} {$tf}");
        ?>
</td>
        <td width="10%"><?php 
        echo $file['file_co_reason'];
        ?>
</td>
        <td nowrap="nowrap" align="center">
        <?php 
        if ($canEdit && empty($row['file_checkout'])) {
            ?>
                <a href="?m=files&a=co&file_id=<?php 
            echo $file['file_id'];
            ?>
"><?php 
            echo dPshowImage('./modules/files/images/up.png', '16', '16', 'checkout', 'checkout file');
            ?>
</a>
        <?php 
        } else {
            if ($row['file_checkout'] == $AppUI->user_id) {
                ?>
                <a href="?m=files&a=addedit&ci=1&file_id=<?php 
                echo $file['file_id'];
                ?>
"><?php 
                echo dPshowImage('./modules/files/images/down.png', '16', '16', 'checkin', 'checkin file');
                ?>
</a>
        <?php 
            } else {
                if ($file['file_checkout'] == 'final') {
                    echo 'final';
                } else {
                    $q4 = new DBQuery();
                    $q4->addQuery("file_id, file_checkout, user_username as co_user, contact_first_name, contact_last_name");
                    $q4->addTable('files');
                    $q4->leftJoin('users', 'cu', 'cu.user_id = file_checkout');
                    $q4->leftJoin('contacts', 'co', 'co.contact_id = cu.user_contact');
                    $q4->addWhere('file_id = ' . $file['file_id']);
                    $co_user = array();
                    $co_user = $q4->loadList();
                    $co_user = $co_user[0];
                    $q4->clear();
                    echo $co_user['contact_first_name'] . ' ' . $co_user['contact_last_name'] . '<br>(' . $co_user['co_user'] . ')';
                }
            }
        }
        ?>
                
        </td>
		<td nowrap="nowrap" align="center" width="48">
		<?php 
        if ($canEdit && (empty($file['file_checkout']) || $file['file_checkout'] == 'final' && ($canEdit || $file['project_owner'] == $AppUI->user_id))) {
            echo '<a href="./index.php?m=files&a=addedit&file_id=' . $file["file_id"] . '">';
            echo dPshowImage('./modules/files/images/kedit.png', '16', '16', 'edit file', 'edit file');
            echo "</a>";
            echo '<a href="#" onclick="document.frm_duplicate_file_' . $file['file_id'] . '.submit()">' . dPshowImage('./modules/files/images/duplicate.png', '16', '16', 'duplicate file', 'duplicate file') . '</a>';
            echo '<a href="#" onclick="if (confirm(\'Are you sure you want to delete this file?\')) {document.frm_remove_file_' . $file['file_id'] . '.submit()}">' . dPshowImage('./modules/files/images/remove.png', '16', '16', 'delete file', 'delete file') . '</a>';
        }
        ?>
		<td nowrap="nowrap" align="center" width="1">
		<?php 
        if ($canEdit && (empty($file['file_checkout']) || $file['file_checkout'] == 'final' && ($canEdit || $file['project_owner'] == $AppUI->user_id))) {
            $bulk_op = 'onchange="(this.checked) ? addBulkComponent(' . $file['file_id'] . ') : removeBulkComponent(' . $file['file_id'] . ')"';
            echo '<input type="checkbox" ' . $bulk_op . ' name="chk_sel_file_' . $file['file_id'] . '" />';
        }
        ?>
		
		</td>
	</tr>
	<?php 
        echo $hidden_table;
        ?>
	<?php 
        $hidden_table = '';
    }
    ?>
	</table>
	<?php 
    if ($xpg_totalrecs > $xpg_pagesize) {
        showfnavbar($xpg_totalrecs, $xpg_pagesize, $xpg_total_pages, $page, $folder);
    }
    echo "<br />";
}
if ($isNewUser) {
    // check if a user with the param Username already exists
    $userEx = FALSE;
    function userExistence($userName)
    {
        global $obj, $userEx;
        if ($userName == $obj->user_username) {
            $userEx = TRUE;
        }
    }
    //pull a list of existing usernames
    $sql = "SELECT user_username FROM users";
    $q = new DBQuery();
    $q->addTable('users', 'u');
    $q->addQuery('user_username');
    $users = $q->loadList();
    // Iterate the above userNameExistenceCheck for each user
    foreach ($users as $usrs) {
        $usrLst = array_map("userExistence", $usrs);
    }
    // If userName already exists quit with error and do nothing
    if ($userEx == TRUE) {
        $AppUI->setMsg("already exists. Try another username.", UI_MSG_ERROR, true);
        $AppUI->redirect();
    }
    $contact->contact_owner = $AppUI->user_id;
}
if ($msg = $contact->store()) {
    $AppUI->setMsg($msg, UI_MSG_ERROR);
} else {
    $obj->user_contact = $contact->contact_id;
Exemple #9
0
function dPgetUsernameFromID($user)
{
    $q = new DBQuery();
    $q->addTable('users');
    $q->addQuery('contact_first_name, contact_last_name');
    $q->addJoin('contacts', 'con', 'contact_id = user_contact');
    $q->addWhere('user_id = \'' . $user . "'");
    $r = $q->loadList();
    return $r[0]['contact_first_name'] . ' ' . $r[0]['contact_last_name'];
}
Exemple #10
0
global $m, $a, $project_id, $task_id, $f;
global $canEdit, $canAccessTask;
$q = new DBQuery();
$q->addTable('tasks');
$q->addQuery('task_id, task_parent, task_name, task_start_date, task_end_date,
	task_dynamic, task_milestone');
if (isset($project_id)) {
    $q->addWhere('task_project=' . $project_id);
} else {
    if ($task_id) {
        $q->addWhere('task_parent=' . $task_id);
        $q->addWhere('task_id !=' . $task_id);
    }
}
$q->addOrder('task_order');
$p['tasks'] = $q->loadList();
$q->clear();
if ($p['tasks']) {
    global $tasks_filtered, $children_of;
    //get list of task ids and set-up array of children
    foreach ($p['tasks'] as $i => $t) {
        $tasks_filtered[] = $t['task_id'];
        $children_of[$t['task_parent']] = $children_of[$t['task_parent']] ? $children_of[$t['task_parent']] : array();
        if ($t['task_parent'] != $t['task_id']) {
            array_push($children_of[$t['task_parent']], $t['task_id']);
        }
    }
    ?>

		
		<?php 
Exemple #11
0
/* COMPANIES $Id: vw_users.php,v 1.12.4.2 2007/03/06 00:34:40 merlinyoda Exp $ */
if (!defined('DP_BASE_DIR')) {
    die('You should not access this file directly.');
}
##
##	Companies: View User sub-table
##
global $AppUI, $company_id;
$q = new DBQuery();
$q->addTable('users');
$q->addQuery('user_id, user_username, contact_first_name, contact_last_name');
$q->addJoin('contacts', 'c', 'users.user_contact = contact_id');
$q->addWhere('contact_company = ' . $company_id);
$q->addOrder('contact_last_name');
if (!($rows = $q->loadList())) {
    echo $AppUI->_('No data available') . '<br />' . $AppUI->getMsg();
} else {
    ?>
<table width="100%" border=0 cellpadding="2" cellspacing="1" class="tbl">
<tr>
	<th><?php 
    echo $AppUI->_('Username');
    ?>
</td>
	<th><?php 
    echo $AppUI->_('Name');
    ?>
</td>
</tr>
<?php 
 public function w2Psearch_acl($application = 'application', $op, $user = '******', $userid, $module)
 {
     global $w2p_performance_acltime, $w2p_performance_aclchecks;
     $q = new DBQuery();
     $q->addTable($this->_db_acl_prefix . 'permissions');
     $q->addQuery('acl_id, access, item_id');
     $q->addWhere('module = \'' . $module . '\'');
     $q->addWhere('action = \'' . $op . '\'');
     $q->addWhere('user_id = ' . (int) $userid);
     $q->addOrder('acl_id DESC');
     if (W2P_PERFORMANCE_DEBUG) {
         $startTime = array_sum(explode(' ', microtime()));
     }
     $res = $q->loadList();
     if (W2P_PERFORMANCE_DEBUG) {
         ++$w2p_performance_aclchecks;
         $w2p_performance_acltime += array_sum(explode(' ', microtime())) - $startTime;
     }
     return $res;
 }
Exemple #13
0
 public function getCompanyList($AppUI, $companyType = -1, $searchString = '', $ownerId = 0, $orderby = 'company_name', $orderdir = 'ASC')
 {
     $q = new DBQuery();
     $q->addTable('companies', 'c');
     $q->addQuery('c.company_id, c.company_name, c.company_type, c.company_description, count(distinct p.project_id) as countp, count(distinct p2.project_id) as inactive, con.contact_first_name, con.contact_last_name');
     $q->addJoin('projects', 'p', 'c.company_id = p.project_company AND p.project_active = 1');
     $q->addJoin('users', 'u', 'c.company_owner = u.user_id');
     $q->addJoin('contacts', 'con', 'u.user_contact = con.contact_id');
     $q->addJoin('projects', 'p2', 'c.company_id = p2.project_company AND p2.project_active = 0');
     $where = $this->getAllowedSQL($AppUI->user_id, 'c.company_id');
     $q->addWhere($where);
     if ($companyType > -1) {
         $q->addWhere('c.company_type = ' . (int) $companyType);
     }
     if ($searchString != '') {
         $q->addWhere('c.company_name LIKE "%' . $searchString . '%"');
     }
     if ($ownerId > 0) {
         $q->addWhere('c.company_owner = ' . $ownerId);
     }
     $q->addGroup('c.company_id');
     $q->addOrder($orderby . ' ' . $orderdir);
     return $q->loadList();
 }
Exemple #14
0
 /**
 * Gets a list of the modules that should appear in the menu
 * @return array Named array list in the form
 * ['module directory', 'module name', 'module_icon']
 */
 function getMenuModules()
 {
     $q = new DBQuery();
     $q->addTable('modules');
     $q->addQuery('mod_directory, mod_ui_name, mod_ui_icon');
     $q->addWhere('mod_active > 0 AND mod_ui_active > 0 AND mod_directory <> \'public\'');
     $q->addWhere('mod_type != \'utility\'');
     $q->addOrder('mod_ui_order');
     return $q->loadList();
 }
Exemple #15
0
	</td>
</tr>

</table>
</form>

<table cellspacing="0" cellpadding="0" border="1" align="center">
<tr>
	<td>
<?php 
if ($a != 'todo') {
    $q = new DBQuery();
    $q->addTable('tasks');
    $q->addQuery('COUNT(*) AS N');
    $q->addWhere('task_project=' . $project_id);
    $cnt = $q->loadList();
    $q->clear();
} else {
    $cnt[0]['N'] = empty($tasks) ? 0 : 1;
}
if ($cnt[0]['N'] > 0) {
    $src = '?m=tasks&amp;a=gantt&amp;suppressHeaders=1&amp;project_id=' . $project_id . ($display_option == 'all' ? '' : '&amp;start_date=' . $start_date->format('%Y-%m-%d') . '&amp;end_date=' . $end_date->format('%Y-%m-%d')) . "&width='" . "+((navigator.appName=='Netscape'?window.innerWidth:document.body.offsetWidth)*0.95)" . "+'&amp;showLabels=" . $showLabels . '&amp;showWork=' . $showWork . '&amp;sortByName=' . $sortByName . '&amp;showPinned=' . $showPinned . '&amp;showArcProjs=' . $showArcProjs . '&amp;showHoldProjs=' . $showHoldProjs . '&amp;showDynTasks=' . $showDynTasks . '&amp;showLowTasks=' . $showLowTasks . '&amp;caller=' . $a . '&amp;user_id=' . $user_id;
    ?>
	<script type="text/javascript">document.write('<img src="<?php 
    echo $src;
    ?>
" alt="" />')</script>
<?php 
    //If we have a problem displaying this we need to display a warning.
    //Put it at the bottom just in case
    if (!dPcheckMem(32 * 1024 * 1024)) {
Exemple #16
0
 public function getAllowedTaskList($AppUI, $task_project = 0)
 {
     $q = new DBQuery();
     $q->addQuery('task_id, task_name, task_parent, task_access, task_owner');
     $q->addOrder('task_parent, task_parent = task_id desc');
     $q->addTable('tasks', 't');
     if ($task_project) {
         $q->addWhere('task_project = ' . (int) $task_project);
     }
     $task_list = $q->loadList();
     foreach ($task_list as $task) {
         if (canTaskAccess($task['task_id'], $task['task_access'], $task['task_owner'])) {
             $results[] = $task;
         }
     }
     return $results;
 }
Exemple #17
0
 public function notifyContacts($notifyContacts)
 {
     global $AppUI, $w2Pconfig, $locale_char_set;
     if ($notifyContacts == '1') {
         //if no project specified than we will not do anything
         if ($this->file_project != 0) {
             $this->_project = new CProject();
             $this->_project->load($this->file_project);
             $mail = new Mail();
             if ($this->file_task == 0) {
                 //notify all developers
                 $mail->Subject($AppUI->_('Project') . ': ' . $this->_project->project_name . '::' . $this->file_name, $locale_char_set);
             } else {
                 //notify all assigned users
                 $this->_task = new CTask();
                 $this->_task->load($this->file_task);
                 $mail->Subject($AppUI->_('Project') . ': ' . $this->_project->project_name . '::' . $this->_task->task_name . '::' . $this->file_name, $locale_char_set);
             }
             $body = $AppUI->_('Project') . ': ' . $this->_project->project_name;
             $body .= "\n" . $AppUI->_('URL') . ':     ' . W2P_BASE_URL . '/index.php?m=projects&a=view&project_id=' . $this->_project->project_id;
             if (intval($this->_task->task_id) != 0) {
                 $body .= "\n\n" . $AppUI->_('Task') . ':    ' . $this->_task->task_name;
                 $body .= "\n" . $AppUI->_('URL') . ':     ' . W2P_BASE_URL . '/index.php?m=tasks&a=view&task_id=' . $this->_task->task_id;
                 $body .= "\n" . $AppUI->_('Description') . ":\n" . $this->_task->task_description;
                 $q = new DBQuery();
                 $q->addTable('project_contacts', 'pc');
                 $q->addQuery('c.contact_email as contact_email, c.contact_first_name as contact_first_name, c.contact_last_name as contact_last_name');
                 $q->addJoin('contacts', 'c', 'c.contact_id = pc.contact_id');
                 $q->addWhere('pc.project_id = ' . (int) $this->_project->project_id);
                 $sql = '(' . $q->prepare() . ')';
                 $q->clear();
                 $sql .= ' UNION ';
                 $q->addTable('task_contacts', 'tc');
                 $q->addQuery('c.contact_email as contact_email, c.contact_first_name as contact_first_name, c.contact_last_name as contact_last_name');
                 $q->addJoin('contacts', 'c', 'c.contact_id = tc.contact_id');
                 $q->addWhere('tc.task_id = ' . (int) $this->_task->task_id);
                 $sql .= '(' . $q->prepare() . ')';
                 $q->clear();
                 $this->_users = $q->loadList();
             } else {
                 $q = new DBQuery();
                 $q->addTable('project_contacts', 'pc');
                 $q->addQuery('pc.project_id, pc.contact_id');
                 $q->addQuery('c.contact_email as contact_email, c.contact_first_name as contact_first_name, c.contact_last_name as contact_last_name');
                 $q->addJoin('contacts', 'c', 'c.contact_id = pc.contact_id');
                 $q->addWhere('pc.project_id = ' . (int) $this->file_project);
                 $this->_users = $q->loadList();
                 $q->clear();
             }
             $body .= "\n\nFile " . $this->file_name . ' was ' . $this->_message . ' by ' . $AppUI->user_first_name . ' ' . $AppUI->user_last_name;
             if ($this->_message != 'deleted') {
                 $body .= "\n" . $AppUI->_('URL') . ':     ' . W2P_BASE_URL . '/fileviewer.php?file_id=' . $this->file_id;
                 $body .= "\n" . $AppUI->_('Description') . ":\n" . $this->file_description;
             }
             //send mail
             $mail->Body($body, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : '');
             foreach ($this->_users as $row) {
                 if ($mail->ValidEmail($row['contact_email'])) {
                     $mail->To($row['contact_email'], true);
                     $mail->Send();
                 }
             }
             return '';
         }
     }
 }
Exemple #18
0
<?php 
    }
    ?>
	</td>
	<?php 
    if (dPgetParam($_REQUEST, "tab", 0) == 0) {
        ?>
	<td>
	       <?php 
        $q = new DBQuery();
        $q->addTable('user_access_log', 'ual');
        $q->addQuery("user_access_log_id, ( unix_timestamp( now( ) ) - unix_timestamp( date_time_in ) ) / 3600 as \t\thours, ( unix_timestamp( now( ) ) - unix_timestamp( date_time_last_action ) ) / 3600 as \t\tidle, if(isnull(date_time_out) or date_time_out ='0000-00-00 00:00:00','1','0') as online");
        $q->addWhere("user_id ='" . $row["user_id"] . "'");
        $q->addOrder('user_access_log_id DESC');
        $q->setLimit(1);
        $user_logs = $q->loadList();
        if ($user_logs) {
            foreach ($user_logs as $row_log) {
                if ($row_log["online"] == '1') {
                    echo '<span style="color: green">' . $row_log["hours"] . " " . $AppUI->_('hrs.') . "( " . $row_log["idle"] . " " . $AppUI->_('hrs.') . " " . $AppUI->_('idle') . ") - " . $AppUI->_('Online');
                } else {
                    echo '<span style="color: red">' . $AppUI->_('Offline');
                }
            }
        } else {
            echo '<span style="color: grey">' . $AppUI->_('Never Visited');
        }
        echo '</span>';
    }
    ?>
	</td>
 function CustomFields($m, $a, $obj_id = NULL, $mode = "edit")
 {
     $this->m = $m;
     $this->a = 'addedit';
     // only addedit pages can carry the custom field for now
     $this->obj_id = $obj_id;
     $this->mode = $mode;
     // Get Custom Fields for this Module
     $q = new DBQuery();
     $q->addTable('custom_fields_struct');
     $q->addWhere("field_module = '" . $this->m . "' AND\tfield_page = '" . $this->a . "'");
     $q->addOrder('field_order ASC');
     $rows = $q->loadList();
     if ($rows == NULL) {
         // No Custom Fields Available
     } else {
         foreach ($rows as $row) {
             switch ($row["field_htmltype"]) {
                 case "checkbox":
                     $this->fields[$row["field_name"]] = new CustomFieldCheckbox($row["field_id"], $row["field_name"], $row["field_order"], stripslashes($row["field_description"]), stripslashes($row["field_extratags"]));
                     break;
                 case "textarea":
                     $this->fields[$row["field_name"]] = new CustomFieldTextArea($row["field_id"], $row["field_name"], $row["field_order"], stripslashes($row["field_description"]), stripslashes($row["field_extratags"]));
                     break;
                 case "select":
                     $this->fields[$row["field_name"]] = new CustomFieldSelect($row["field_id"], $row["field_name"], $row["field_order"], stripslashes($row["field_description"]), stripslashes($row["field_extratags"]));
                     break;
                 case "label":
                     $this->fields[$row["field_name"]] = new CustomFieldLabel($row["field_id"], $row["field_name"], $row["field_order"], stripslashes($row["field_description"]), stripslashes($row["field_extratags"]));
                     break;
                 case "separator":
                     $this->fields[$row["field_name"]] = new CustomFieldSeparator($row["field_id"], $row["field_name"], $row["field_order"], stripslashes($row["field_description"]), stripslashes($row["field_extratags"]));
                     break;
                 default:
                     $this->fields[$row["field_name"]] = new CustomFieldText($row["field_id"], $row["field_name"], $row["field_order"], stripslashes($row["field_description"]), stripslashes($row["field_extratags"]));
                     break;
             }
         }
         if ($obj_id > 0) {
             //Load Values
             foreach ($this->fields as $key => $cfield) {
                 $this->fields[$key]->load($this->obj_id);
             }
         }
     }
 }
 function search($moduleTable, $moduleTableId, $moduleTableName, $keyword)
 {
     $q = new DBQuery();
     $q->addTable('custom_fields_values', 'cfv');
     $q->addQuery('m.' . $moduleTableId);
     $q->addQuery('m.' . $moduleTableName);
     $q->addQuery('cfv.value_charvalue');
     $q->addJoin('custom_fields_struct', 'cfs', 'cfs.field_id = cfv.value_field_id');
     $q->addJoin($moduleTable, 'm', 'm.' . $moduleTableId . ' = cfv. value_object_id');
     $q->addWhere('cfs.field_module = "' . $this->m . '"');
     $q->addWhere('cfv.value_charvalue LIKE "%' . $keyword . '%"');
     return $q->loadList();
 }
Exemple #21
0
global $AppUI, $w2Pconfig, $cal_df, $cf;
// check permissions for this module
$perms =& $AppUI->acl();
$canView = $perms->checkModule($m, 'view');
$canAddProject = $perms->checkModuleItem('projects', 'view', $project_id);
if (!$canView) {
    $AppUI->redirect('m=public&a=access_denied');
}
$AppUI->loadCalendarJS();
$today = new CDate();
//Lets load the users panel viewing options
$q = new DBQuery();
$q->addTable('project_designer_options', 'pdo');
$q->addQuery('pdo.*');
$q->addWhere('pdo.pd_option_user = '******'project_id', 0);
$project_id = (int) w2PgetParam($_GET, 'project_id', $project_id);
$extra = array('where' => 'project_active = 1');
$project = new CProject();
$projects = $project->getAllowedRecords($AppUI->user_id, 'projects.project_id,project_name', 'project_name', null, $extra, 'projects');
$q = new DBQuery();
$q->addTable('projects');
$q->addQuery('projects.project_id, company_name');
$q->addJoin('companies', 'co', 'co.company_id = project_company');
$idx_companies = $q->loadHashList();
$q->clear();
foreach ($projects as $prj_id => $prj_name) {
    $projects[$prj_id] = $idx_companies[$prj_id] . ': ' . $prj_name;
}
asort($projects);
Exemple #22
0
$q->addTable('tasks', 't');
$q->innerJoin('projects', 'p', 'p.project_id = t.task_project');
$q->addQuery('t.*, p.project_name, p.project_id, p.project_color_identifier');
if ($project_id) {
    $q->addWhere('p.project_id = ' . $project_id);
}
if (count($allowedTasks)) {
    $q->addWhere($allowedTasks);
}
if (count($allowedProjects)) {
    $q->addWhere($allowedProjects);
}
$q->addGroup('t.task_id');
$q->addOrder($sort . ', t.task_priority DESC');
//echo ('<pre>' . $q->prepare(); . '</pre>');
$tasks = $q->loadList();
$priorities = array('1' => 'high', '0' => 'normal', '-1' => 'low');
$durnTypes = dPgetSysVal('TaskDurationType');
if (!@$min_view) {
    $titleBlock = new CTitleBlock('Organize Tasks', 'applet-48.png', $m, "{$m}.{$a}");
    $titleBlock->addCrumb('?m=tasks', 'tasks list');
    if ($project_id) {
        $titleBlock->addCrumb('?m=projects&a=view&project_id=' . $project_id, 'view project');
    }
    $titleBlock->show();
}
function showchildren($id, $level = 1)
{
    global $tasks;
    $t = $tasks;
    //otherwise, $tasks is accessed from a static context and doesn't work.
Exemple #23
0
$q->addJoin('projects', 'p2', 'c.company_id = p2.project_company AND p2.project_status = 7');
if (count($allowedCompanies) > 0) {
    $q->addWhere('c.company_id IN (' . implode(',', array_keys($allowedCompanies)) . ')');
}
if ($companiesType) {
    $q->addWhere('c.company_type = ' . $company_type_filter);
}
if ($search_string != "") {
    $q->addWhere("c.company_name LIKE '%{$search_string}%'");
}
if ($owner_filter_id > 0) {
    $q->addWhere("c.company_owner = {$owner_filter_id} ");
}
$q->addGroup('c.company_id');
$q->addOrder($orderby . ' ' . $orderdir);
$rows = $q->loadList();
?>
<table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl">
<tr>
	<td nowrap="nowrap" width="60" align="right">&nbsp;<?php 
echo $AppUI->_('sort by');
?>
:&nbsp;</td>
	<th nowrap="nowrap">
		<a href="?m=companies&orderby=company_name" class="hdr"><?php 
echo $AppUI->_('Company Name');
?>
</a>
	</th>
	<th nowrap="nowrap">
		<a href="?m=companies&orderby=countp" class="hdr"><?php 
Exemple #24
0
}
$stub = $AppUI->getState('UserIdxStub');
$where = $AppUI->getState('UserIdxWhere');
$valid_ordering = array('user_username', 'contact_last_name', 'contact_company', 'date_time_in', 'user_ip');
if (isset($_GET['orderby']) && in_array($_GET['orderby'], $valid_ordering)) {
    $AppUI->setState('UserIdxOrderby', $_GET['orderby']);
}
$orderby = $AppUI->getState('UserIdxOrderby') ? $AppUI->getState('UserIdxOrderby') : 'user_username';
$orderby = $tab == 3 || $orderby != 'date_time_in' && $orderby != 'user_ip' ? $orderby : 'user_username';
$q = new DBQuery();
// Pull First Letters
$let = ":";
$q->addTable('users', 'u');
$q->addJoin('contacts', 'con', 'con.contact_id = u.user_contact');
$q->addQuery('DISTINCT UPPER(SUBSTRING(u.user_username, 1, 1)) AS L' . ', UPPER(SUBSTRING(con.contact_first_name, 1, 1)) AS CF' . ', UPPER(SUBSTRING(con.contact_last_name, 1, 1)) AS CL');
$arr = $q->loadList();
foreach ($arr as $L) {
    foreach ($L as $v) {
        if (empty($v)) {
            continue;
        }
        if (empty($let)) {
            $let .= $v;
        } else {
            $let .= mb_strpos($let, $v) === false ? $v : '';
        }
    }
}
$q->clear();
$a2z = "\n" . '<table cellpadding="2" cellspacing="1" border="0">';
$a2z .= "\n<tr>";
Exemple #25
0
$date = new CDate();
$pdfdata = array();
$pdfhead = array('Date', 'User', 'Message');
$new_messages = array();
foreach ($messages as $row) {
    // Find the parent message - the topic.
    if ($row['message_id'] == $message_id) {
        $topic = $row['message_title'];
    }
    $q = new DBQuery();
    $q->addTable('forum_messages');
    $q->addTable('users', 'u');
    $q->addQuery('DISTINCT contact_email, contact_first_name, contact_last_name, user_username');
    $q->addJoin('contacts', 'con', 'contact_id = user_contact');
    $q->addWhere('u.user_id = ' . $row["message_editor"]);
    $editor = $q->loadList();
    $date = intval($row["message_date"]) ? new CDate($row["message_date"]) : null;
    $pdfdata[] = array($row['message_date'], $row['contact_first_name'] . ' ' . $row['contact_last_name'], '<b>' . $row['message_title'] . '</b>
		' . $row['message_body']);
}
$font_dir = DP_BASE_DIR . '/lib/ezpdf/fonts';
$temp_dir = DP_BASE_DIR . '/files/temp';
require $AppUI->getLibraryClass('ezpdf/class.ezpdf');
$pdf =& new Cezpdf($paper = 'A4', $orientation = 'portrait');
$pdf->ezSetCmMargins(1, 2, 1.5, 1.5);
$pdf->selectFont("{$font_dir}/Helvetica.afm");
$pdf->ezText('Project: ' . $forum['project_name'] . '   Forum: ' . $forum['forum_name']);
$pdf->ezText('Topic: ' . $topic);
$pdf->ezText('');
$options = array('showLines' => 1, 'showHeadings' => 1, 'fontSize' => 8, 'rowGap' => 2, 'colGap' => 5, 'xPos' => 50, 'xOrientation' => 'right', 'width' => '500');
$pdf->ezTable($pdfdata, $pdfhead, NULL, $options);
 function getCriticalTasks($project_id = NULL, $limit = 1)
 {
     $project_id = !empty($project_id) ? $project_id : $this->project_id;
     $q = new DBQuery();
     $q->addTable('tasks');
     if ($project_id) {
         $q->addWhere('task_project = ' . $project_id);
     }
     $q->addWhere("!isnull(task_end_date) AND task_end_date !=  '0000-00-00 00:00:00'");
     $q->addOrder('task_end_date DESC');
     $q->setLimit($limit);
     return $q->loadList();
 }
Exemple #27
0
if ($showInactive != '1') {
    $filter1[] = ' project_status <> 7';
}
$pjobj =& new CProject();
$allowed_projects = $pjobj->getAllowedSQL($AppUI->user_id);
$where = array_merge($filter1, $allowed_projects);
// pull valid projects and their percent complete information
$q = new DBQuery();
$q->addTable('tasks', 't');
$q->addJoin('user_tasks', 'ut', 't.task_id = ut.task_id');
$q->addJoin('users', 'u', 'u.user_id = ut.user_id');
$q->addJoin('projects', 'p', 'p.project_id = t.task_project');
$q->addJoin('companies', 'c', 'p.project_company = c.company_id');
$q->addQuery('u.user_username, t.task_name, t.task_start_date, t.task_milestone' . ', ut.perc_assignment, t.task_end_date, t.task_dynamic' . ', p.project_color_identifier, p.project_name');
$q->addOrder('t.task_name, t.task_start_date, t.task_end_date, ut.perc_assignment');
$tasks = $q->loadList();
$q->clear();
$q->addTable('user_tasks', 'ut');
$q->innerJoin('users', 'u', 'u.user_id = ut.user_id');
$q->innerJoin('tasks', 't', 't.task_id = ut.task_id');
$q->addQuery('min(t.task_start_date) AS task_min_date, max(t.task_end_date) AS task_max_date');
$taskMinMax = $q->loadList();
$q->clear();
$width = dPgetParam($_GET, 'width', 600);
$start_date = dPgetParam($_GET, 'start_date', 0);
$end_date = dPgetParam($_GET, 'end_date', 0);
$showTaskGantt = dPgetParam($_GET, 'showTaskGantt', 0);
$graph2 = new GanttGraph($width);
$graph2->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH | GANTT_HDAY | GANTT_HWEEK);
$graph2->SetFrame(false);
$graph2->SetBox(true, array(0, 0, 0), 2);
Exemple #28
0
$q->leftJoin('contacts', 'con', 'contact_id = user_contact');
$q->leftJoin('forum_messages', 'fm2', 'fm1.message_id = fm2.message_parent');
$q->leftJoin('forum_watch', 'fw', 'watch_user = '******' AND watch_topic = fm1.message_id');
$q->leftJoin('forum_visits', 'v1', 'v1.visit_user = '******' AND v1.visit_message = fm1.message_id');
$q->addWhere('fm1.message_forum = ' . (int) $forum_id);
switch ($f) {
    case 1:
        $q->addWhere('watch_user IS NOT NULL');
        break;
    case 2:
        $q->addWhere('(NOW() < DATE_ADD(fm2.message_date, INTERVAL 30 DAY) OR NOW() < DATE_ADD(fm1.message_date, INTERVAL 30 DAY))');
        break;
}
$q->addGroup('fm1.message_id, fm1.message_parent');
$q->addOrder($orderby . ' ' . $orderdir);
$topics = $q->loadList();
$crumbs = array();
$crumbs['?m=forums'] = 'forums list';
?>
<br />
<?php 
if (function_exists('styleRenderBoxTop')) {
    echo styleRenderBoxTop();
}
?>
<table width="100%" cellspacing="1" cellpadding="2" border="0" class="tbl">
<form name="watcher" action="?m=forums&a=viewer&forum_id=<?php 
echo $forum_id;
?>
&f=<?php 
echo $f;
<?php

if (!defined('DP_BASE_DIR')) {
    die('You should not access this file directly.');
}
$AppUI->savePlace();
require_once $AppUI->getSystemClass('CustomFields');
$titleBlock = new CTitleBlock('Custom field editor', 'customfields.png', 'admin', 'admin.custom_field_editor');
$titleBlock->addCrumb('?m=system', 'system admin');
$edit_field_id = dpGetParam($_POST, 'field_id', NULL);
$titleBlock->show();
$sql = 'SELECT * FROM modules' . ' ORDER BY mod_ui_order';
$q = new DBQuery();
$q->addTable('modules');
$q->addWhere('mod_name IN (\'Companies\', \'Projects\', \'Tasks\', \'Calendar\')');
$modules = $q->loadList();
echo '<table cellpadding="2" summary="module list">';
foreach ($modules as $module) {
    echo '<tr><td colspan="4">';
    echo '<h3>' . $AppUI->_($module['mod_name']) . '</h3>';
    echo '</td></tr>';
    echo '<tr><td colspan="4">';
    echo '<a href="?m=system&amp;a=custom_field_addedit&amp;module=' . $module['mod_name'] . '"><img src="./images/icons/stock_new.png" align="center" width="16" height="16" border="0" alt="" />' . $AppUI->_('Add a new Custom Field to this Module') . '</a><br /><br />';
    echo '</td></tr>';
    $q->clear();
    $q->addTable('custom_fields_struct');
    $q->addWhere('field_module = \'' . mb_strtolower($module['mod_name']) . "'");
    $custom_fields = $q->loadList();
    foreach ($custom_fields as $f) {
        echo '<tr><td class="hilite">';
        echo '<a href="?m=system&amp;a=custom_field_addedit&amp;module=' . $module['mod_name'] . '&amp;field_id=' . $f['field_id'] . '"><img src="./images/icons/stock_edit-16.png" align="center" width="16" height="16" border="0" alt="" />Edit</a>';
 /**
 * Utility function to return an array of events with a period
 * @param Date Start date of the period
 * @param Date End date of the period
 * @return array A list of events
 */
 function getEventsForPeriod($start_date, $end_date, $filter = 'all', $user_id = null)
 {
     global $AppUI;
     // the event times are stored as unix time stamps, just to be different
     // convert to default db time stamp
     $db_start = $start_date->format(FMT_DATETIME_MYSQL);
     $db_end = $end_date->format(FMT_DATETIME_MYSQL);
     if (!isset($user_id)) {
         $user_id = $AppUI->user_id;
     }
     $project =& new CProject();
     $allowedProjects = $project->getAllowedSQL($user_id, 'event_project');
     $q = new DBQuery();
     $q->addTable('events', 'e');
     $q->addQuery('e.*');
     if (count($allowedProjects)) {
         $q->addWhere('( ( ' . implode(' AND ', $allowedProjects) . ") OR event_project = 0 )");
         $q->addJoin('projects', 'p', 'p.project_id = e.event_project');
     }
     switch ($filter) {
         case 'my':
             $q->addJoin('user_events', 'ue', 'ue.event_id = e.event_id AND ue.user_id =' . $user_id);
             $q->addWhere("( ( event_private = 0 AND ue.user_id = {$user_id} )\n\t\t\t\t\t\tOR event_owner={$user_id} )");
             break;
         case 'own':
             $q->addWhere("( event_owner = {$user_id} )");
             break;
         case 'all':
             $q->addWhere("( event_private=0 OR (event_private=1 AND event_owner={$user_id}) )");
             break;
     }
     $q->addWhere("( event_start_date <= '{$db_end}' AND event_end_date >= '{$db_start}'\n\t\t\t\tOR event_start_date BETWEEN '{$db_start}' AND '{$db_end}')");
     // duplicate query object for recursive events;
     $r = $q;
     // assemble query for non-recursive events
     $q->addWhere('( event_recurs <= 0 )');
     $eventList = $q->loadList();
     // assemble query for recursive events
     $r->addWhere('( event_recurs > 0 )');
     $eventListRec = $r->loadList();
     //Calculate the Length of Period (Daily, Weekly, Monthly View)
     $periodLength = Date_Calc::dateDiff($start_date->getDay(), $start_date->getMonth(), $start_date->getYear(), $end_date->getDay(), $end_date->getMonth(), $end_date->getYear());
     // AJD: Should this be going off the end of the array?  I don't think so.
     // If it should then a comment to that effect would be nice.
     // for ($i=0; $i < sizeof($eventListRec)+1;  $i++) {
     for ($i = 0; $i < sizeof($eventListRec); $i++) {
         for ($j = 0; $j < intval($eventListRec[$i]['event_times_recuring']); $j++) {
             //Daily View
             //show all
             if ($periodLength == 1) {
                 $recEventDate = CEvent::getRecurrentEventforPeriod($start_date, $end_date, $eventListRec[$i]['event_start_date'], $eventListRec[$i]['event_end_date'], $eventListRec[$i]['event_recurs'], $eventListRec[$i]['event_times_recuring'], $j);
             } elseif ($periodLength > 1 && $eventListRec[$i]['event_recurs'] == 1 && $j == 0) {
                 $recEventDate = CEvent::getRecurrentEventforPeriod($start_date, $end_date, $eventListRec[$i]['event_start_date'], $eventListRec[$i]['event_end_date'], $eventListRec[$i]['event_recurs'], $eventListRec[$i]['event_times_recuring'], $j);
                 $eventListRec[$i]['event_title'] = $eventListRec[$i]['event_title'] . " (" . $AppUI->_('Hourly') . ")";
             } elseif ($periodLength > 1 && $eventListRec[$i]['event_recurs'] > 1) {
                 $recEventDate = CEvent::getRecurrentEventforPeriod($start_date, $end_date, $eventListRec[$i]['event_start_date'], $eventListRec[$i]['event_end_date'], $eventListRec[$i]['event_recurs'], $eventListRec[$i]['event_times_recuring'], $j);
             }
             //add values to the eventsArray if check for recurrent event was positive
             if (sizeof($recEventDate) > 0) {
                 $eList[0] = $eventListRec[$i];
                 $eList[0]['event_start_date'] = $recEventDate[0]->format(FMT_DATETIME_MYSQL);
                 $eList[0]['event_end_date'] = $recEventDate[1]->format(FMT_DATETIME_MYSQL);
                 $eventList = array_merge($eventList, $eList);
             }
             // clear array of positive recurrent events for the case that next loop recEventDate is empty in order to avoid double display
             $recEventDate = array();
         }
     }
     //return a list of non-recurrent and recurrent events
     return $eventList;
 }