當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DBQuery::loadColumn方法代碼示例

本文整理匯總了PHP中DBQuery::loadColumn方法的典型用法代碼示例。如果您正苦於以下問題:PHP DBQuery::loadColumn方法的具體用法?PHP DBQuery::loadColumn怎麽用?PHP DBQuery::loadColumn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DBQuery的用法示例。


在下文中一共展示了DBQuery::loadColumn方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: importTasks

 /**	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);
//.........這裏部分代碼省略.........
開發者ID:srinivasulurao,項目名稱:jonel,代碼行數:101,代碼來源:projects.class.php

示例2: round

    if ($hours > 0) {
        $allpdfdata[$company_name] = $pdfdata;
        echo $table;
        echo '<tr><td>Total</td><td>' . round($hours, 2) . '</td></tr></table>';
    }
    return $hours;
}
if ($do_report) {
    $total = 0;
    $q = new DBQuery();
    $q->addTable('companies');
    $q->addQuery('company_id');
    if (!$fullaccess) {
        $q->addWhere("company_owner='" . $AppUI->user_id . "'");
    }
    $companies = $q->loadColumn();
    if (!empty($companies)) {
        foreach ($companies as $company) {
            $total += showcompany($company);
        }
    } else {
        $q->addTable('companies');
        $q->addQuery('company_id');
        foreach ($q->loadColumn() as $company) {
            $total += showcompany($company, true);
        }
    }
    echo '<h2>' . $AppUI->_('Total Hours') . ":";
    printf("%.2f", $total);
    echo '</h2>';
    if ($log_pdf) {
開發者ID:hoodoogurus,項目名稱:dotprojecteap,代碼行數:31,代碼來源:overall.php

示例3: getReadableModule

function getReadableModule()
{
    global $AppUI;
    $perms =& $AppUI->acl();
    $q = new DBQuery();
    $q->addTable('modules');
    $q->addQuery('mod_directory');
    $q->addWhere('mod_active = 1');
    $q->addOrder('mod_ui_order');
    $modules = $q->loadColumn();
    foreach ($modules as $mod) {
        if ($perms->checkModule($mod, 'access')) {
            return $mod;
        }
    }
    return null;
}
開發者ID:joly,項目名稱:web2project,代碼行數:17,代碼來源:permissions.class.php

示例4: projects_list_data

function projects_list_data($user_id = false)
{
    global $AppUI, $addPwOiD, $buffer, $company, $company_id, $company_prefix, $deny, $department, $dept_ids, $dPconfig, $orderby, $orderdir, $projects, $tasks_critical, $tasks_problems, $tasks_sum, $tasks_summy, $tasks_total, $owner;
    $addProjectsWithAssignedTasks = $AppUI->getState('addProjWithTasks') ? $AppUI->getState('addProjWithTasks') : 0;
    // get any records denied from viewing
    $obj = new CProject();
    $deny = $obj->getDeniedRecords($AppUI->user_id);
    // Let's delete temproary tables
    $q = new DBQuery();
    $q->dropTemp('tasks_sum, tasks_total, tasks_summy, tasks_critical, tasks_problems, tasks_users');
    $q->exec();
    $q->clear();
    // Task sum table
    // by Pablo Roca (pabloroca@mvps.org)
    // 16 August 2003
    $working_hours = $dPconfig['daily_working_hours'] ? $dPconfig['daily_working_hours'] : 8;
    // GJB: Note that we have to special case duration type 24 and this refers to the hours in a day, NOT 24 hours
    $q->createTemp('tasks_sum');
    $q->addTable('tasks');
    $q->addQuery("task_project, SUM(task_duration * task_percent_complete * IF(task_duration_type = 24, {$working_hours}," . " task_duration_type)) / SUM(task_duration * IF(task_duration_type = 24, {$working_hours}," . " task_duration_type)) AS project_percent_complete, SUM(task_duration * IF(task_duration_type = 24," . " {$working_hours}, task_duration_type)) AS project_duration");
    if ($user_id) {
        $q->addJoin('user_tasks', 'ut', 'ut.task_id = tasks.task_id');
        $q->addWhere('ut.user_id = ' . $user_id);
    }
    $q->addWhere("tasks.task_id = tasks.task_parent");
    $q->addGroup('task_project');
    $tasks_sum = $q->exec();
    $q->clear();
    // Task total table
    $q->createTemp('tasks_total');
    $q->addTable('tasks');
    $q->addQuery("task_project, COUNT(distinct tasks.task_id) AS total_tasks");
    if ($user_id) {
        $q->addJoin('user_tasks', 'ut', 'ut.task_id = tasks.task_id');
        $q->addWhere('ut.user_id = ' . $user_id);
    }
    $q->addGroup('task_project');
    $tasks_total = $q->exec();
    $q->clear();
    // temporary My Tasks
    // by Pablo Roca (pabloroca@mvps.org)
    // 16 August 2003
    $q->createTemp('tasks_summy');
    $q->addTable('tasks');
    $q->addQuery('task_project, COUNT(distinct task_id) AS my_tasks');
    if ($user_id) {
        $q->addWhere('task_owner = ' . $user_id);
    } else {
        $q->addWhere('task_owner = ' . $AppUI->user_id);
    }
    $q->addGroup('task_project');
    $tasks_summy = $q->exec();
    $q->clear();
    // temporary critical tasks
    $q->createTemp('tasks_critical');
    $q->addTable('tasks');
    $q->addQuery('task_project, task_id AS critical_task, MAX(task_end_date) AS project_actual_end_date');
    $q->addJoin('projects', 'p', 'p.project_id = task_project');
    $q->addOrder("task_end_date DESC");
    $q->addGroup('task_project');
    $tasks_critical = $q->exec();
    $q->clear();
    // temporary task problem logs
    $q->createTemp('tasks_problems');
    $q->addTable('tasks');
    $q->addQuery('task_project, task_log_problem');
    $q->addJoin('task_log', 'tl', 'tl.task_log_task = task_id');
    $q->addWhere("task_log_problem > '0'");
    $q->addGroup('task_project');
    $tasks_problems = $q->exec();
    $q->clear();
    if ($addProjectsWithAssignedTasks) {
        // temporary users tasks
        $q->createTemp('tasks_users');
        $q->addTable('tasks');
        $q->addQuery('task_project');
        $q->addQuery('ut.user_id');
        $q->addJoin('user_tasks', 'ut', 'ut.task_id = tasks.task_id');
        if ($user_id) {
            $q->addWhere('ut.user_id = ' . $user_id);
        }
        $q->addOrder("task_end_date DESC");
        $q->addGroup('task_project');
        $tasks_users = $q->exec();
        $q->clear();
    }
    // add Projects where the Project Owner is in the given department
    if ($addPwOiD && isset($department)) {
        $owner_ids = array();
        $q->addTable('users');
        $q->addQuery('user_id');
        $q->addJoin('contacts', 'c', 'c.contact_id = user_contact');
        $q->addWhere('c.contact_department = ' . $department);
        $owner_ids = $q->loadColumn();
        $q->clear();
    }
    if (isset($department)) {
        //If a department is specified, we want to display projects from the department, and all departments under that, so we need to build that list of departments
        $dept_ids = array();
        $q->addTable('departments');
//.........這裏部分代碼省略.........
開發者ID:seatecnologia,項目名稱:dotproject_timesheet,代碼行數:101,代碼來源:projects.class.php

示例5: IN

$q->addTable('history', 'h');
$q->leftJoin('users', 'u', 'u.user_id = h.history_user');
$q->addQuery('h.*, u.*');
if ($in_filter) {
    $filter .= ($filter ? ' AND ' : '') . "(h.`history_table` LIKE '" . $in_filter . "%')";
}
if ($denied_tables) {
    $filter .= ($filter ? ' AND ' : '') . "(NOT h.`history_table` IN ('" . $denied_tables . "'))";
}
if (!empty($_REQUEST['project_id'])) {
    $project_id = $_REQUEST['project_id'];
    $r = new DBQuery();
    $r->addTable('tasks');
    $r->addQuery('task_id');
    $r->addWhere('task_project = ' . $project_id);
    $project_tasks = implode(',', $r->loadColumn());
    $r->clear();
    $r->addTable('files');
    $r->addQuery('file_id');
    $r->addWhere('file_project = ' . $project_id);
    $project_files = implode(',', $r->loadColumn());
    $r->clear();
    if (!empty($project_tasks)) {
        $project_tasks = " OR (history_table = 'tasks' AND history_item IN ({$project_tasks})) ";
    }
    if (!empty($project_files)) {
        $project_files = " OR (history_table = 'files' AND history_item IN ({$project_files})) ";
    }
    $filter .= ($filter ? ' AND ' : '') . ("((history_table = 'projects' AND history_item = " . $project_id . ')' . $project_tasks . $project_files . ')');
}
if ($filter) {
開發者ID:TheIdeaMan,項目名稱:dotproject,代碼行數:31,代碼來源:index.php

示例6: implode

// Remove any empty elements
$contacts_id = remove_invalid(explode(',', $selected_contacts_id));
$selected_contacts_id = implode(',', $contacts_id);
require_once $AppUI->getModuleClass('companies');
$oCpy = new CCompany();
$aCpies = $oCpy->getAllowedRecords($AppUI->user_id, 'company_id, company_name', 'company_name');
$aCpies_esc = array();
foreach ($aCpies as $key => $company) {
    $aCpies_esc[$key] = db_escape($company);
}
$q = new DBQuery();
if (mb_strlen($selected_contacts_id) > 0 && !$show_all && !$company_id) {
    $q->addTable('contacts');
    $q->addQuery('DISTINCT contact_company');
    $q->addWhere('contact_id IN (' . $selected_contacts_id . ')');
    $where = implode(',', $q->loadColumn());
    $q->clear();
    if (mb_substr($where, 0, 1) == ',' && $where != ',') {
        $where = '0' . $where;
    } else {
        if ($where == ',') {
            $where = '0';
        }
    }
    $where = $where ? 'contact_company IN(' . $where . ')' : '';
} else {
    if (!$company_id) {
        //  Contacts from all allowed companies
        $where = "contact_company = ''" . " OR (contact_company IN ('" . implode('\',\'', array_values($aCpies_esc)) . "'))" . " OR (contact_company IN ('" . implode('\',\'', array_keys($aCpies_esc)) . "'))";
        $company_name = $AppUI->_('Allowed Companies');
    } else {
開發者ID:222elm,項目名稱:dotprojectFrame,代碼行數:31,代碼來源:contact_selector.php

示例7: testImportTasks

 /**
  * Tests importing tasks from one project to another
  */
 public function testImportTasks()
 {
     $this->obj->load(2);
     $this->obj->importTasks(1);
     $xml_file_dataset = $this->createXMLDataSet($this->getDataSetPath() . 'projectsTestImportTasks.xml');
     $xml_file_filtered_dataset = new PHPUnit_Extensions_Database_DataSet_DataSetFilter($xml_file_dataset, array('tasks' => array('task_created', 'task_updated')));
     $xml_db_dataset = $this->getConnection()->createDataSet();
     $xml_db_filtered_dataset = new PHPUnit_Extensions_Database_DataSet_DataSetFilter($xml_db_dataset, array('tasks' => array('task_created', 'task_updated')));
     $this->assertTablesEqual($xml_file_filtered_dataset->getTable('tasks'), $xml_db_filtered_dataset->getTable('tasks'));
     $now_secs = time();
     $min_time = $now_secs - 10;
     /**
      * Get created dates to test against
      */
     $q = new DBQuery();
     $q->addTable('tasks');
     $q->addQuery('task_created');
     $q->addWhere('task_project = 2');
     $results = $q->loadColumn();
     foreach ($results as $created) {
         $this->assertGreaterThanOrEqual($min_time, strtotime($created));
         $this->assertLessThanOrEqual($now_secs, strtotime($created));
     }
     /**
      * Get updated dates to test against
      */
     $q = new DBQuery();
     $q->addTable('tasks');
     $q->addQuery('task_updated');
     $q->addWhere('task_project = 2');
     $results = $q->loadColumn();
     foreach ($results as $updated) {
         $this->assertGreaterThanOrEqual($min_time, strtotime($updated));
         $this->assertLessThanOrEqual($now_secs, strtotime($updated));
     }
     $xml_dataset = $this->createXMLDataSet($this->getDataSetPath() . 'projectsTestImportTasks.xml');
     $this->assertTablesEqual($xml_dataset->getTable('user_tasks'), $this->getConnection()->createDataSet()->getTable('user_tasks'));
     $this->assertTablesEqual($xml_dataset->getTable('task_dependencies'), $this->getConnection()->createDataSet()->getTable('task_dependencies'));
 }
開發者ID:joly,項目名稱:web2project,代碼行數:42,代碼來源:projects.test.php

示例8: CDpTree

    $tree = new CDpTree();
    $columns = array('<b>' . $AppUI->_('Task Name') . '</b>', '<b>' . $AppUI->_('Task Description') . '</b>', '<b>' . $AppUI->_('Assigned To') . '</b>', '<b>' . $AppUI->_('Task Start Date') . '</b>', '<b>' . $AppUI->_('Task End Date') . '</b>', '<b>' . $AppUI->_('Completion') . '</b>');
    if ($project_id == 0) {
        array_unshift($columns, '<b>' . $AppUI->_('Project Name') . '</b>');
    }
    while ($Tasks = db_fetch_assoc($Task_List)) {
        $Tasks['start_date'] = intval($Tasks['task_start_date']) ? new CDate($Tasks['task_start_date']) : ' ';
        $Tasks['end_date'] = intval($Tasks['task_end_date']) ? new CDate($Tasks['task_end_date']) : ' ';
        $task_id = $Tasks['task_id'];
        $q = new DBQuery();
        $q->addQuery("CONCAT_WS(' ', c.contact_first_name, c.contact_last_name)" . ' as contact_name');
        $q->addTable('user_tasks', 'ut');
        $q->leftJoin('users', 'u', 'u.user_id = ut.user_id');
        $q->leftJoin('contacts', 'c', 'c.contact_id = u.user_contact');
        $q->addWhere('ut.task_id = ' . $task_id);
        $sql_user = $q->loadColumn();
        $Tasks['users'] = implode(', ', $sql_user);
        $tree->add($Tasks['task_parent'], $task_id, $Tasks);
        unset($Tasks);
    }
    // Now show the tasks as HTML
    $tree->display('show_task_as_html');
    ?>
</table>

<?php 
    if ($log_pdf) {
        // make the PDF file
        $pdfdata = array();
        $tree->display('collate_pdf_task');
        $q = new DBQuery();
開發者ID:hoodoogurus,項目名稱:dotprojecteap,代碼行數:31,代碼來源:tasklist.php

示例9: DBQuery

</th>
	</tr>

<?php 
    if (count($user_list)) {
        $percentage_sum = $hours_allocated_sum = $hours_worked_sum = 0;
        $sum_total_hours_allocated = $sum_total_hours_worked = 0;
        $sum_hours_allocated_complete = $sum_hours_worked_complete = 0;
        //TODO: Split times for which more than one users were working...
        $q = new DBQuery();
        foreach ($user_list as $user_id => $user) {
            $q->clear();
            $q->addTable('user_tasks');
            $q->addQuery('task_id');
            $q->addWhere('user_id = ' . (int) $user_id);
            $tasks_id = $q->loadColumn();
            $total_hours_allocated = $total_hours_worked = 0;
            $hours_allocated_complete = $hours_worked_complete = 0;
            foreach ($tasks_id as $task_id) {
                if (isset($task_list[$task_id])) {
                    // Now let's figure out how many time did the user spent in this task
                    $q->clear();
                    $q->addTable('task_log');
                    $q->addQuery('sum(task_log_hours)');
                    $q->addWhere('task_log_task = ' . (int) $task_id);
                    $q->addWhere('task_log_creator = ' . (int) $user_id);
                    $hours_worked = round($q->loadResult(), 2);
                    $q->clear();
                    $q->addTable('tasks');
                    $q->addQuery('task_percent_complete');
                    $q->addWhere('task_id = ' . (int) $task_id);
開發者ID:srinivasulurao,項目名稱:jonel,代碼行數:31,代碼來源:userperformance.php

示例10: getUserDeptId

 public static function getUserDeptId($user_id)
 {
     $q = new DBQuery();
     $q->addQuery('con.contact_department');
     $q->addTable('users', 'u');
     $q->addJoin('contacts', 'con', 'user_contact = contact_id', 'inner');
     $q->addWhere('u.user_id = ' . (int) $user_id);
     $user_dept = $q->loadColumn();
     $q->clear();
     return $user_dept;
 }
開發者ID:joly,項目名稱:web2project,代碼行數:11,代碼來源:admin.class.php

示例11: getAllowedItems

 function getAllowedItems($module, $uid = null)
 {
     // Checking in dotpermissions..
     // Is getAllowedItems operation-independent???
     $items = array();
     if (!$uid) {
         $uid = $GLOBALS['AppUI']->user_id;
     }
     // Bug found by Anne (dotproject forum) -- Changed from "allow=0" to "allow!=0"
     $q = new DBQuery();
     $q->addQuery('distinct axo');
     $q->addTable('dotpermissions');
     $q->addWhere("allow!=0 AND user_id={$uid} AND section='{$module}' AND enabled=1");
     $items = $q->loadColumn();
     dprint(__FILE__, __LINE__, 2, "getAllowedItems({$module}, {$uid}) returning " . count($items) . ' items');
     return $items;
 }
開發者ID:222elm,項目名稱:dotprojectFrame,代碼行數:17,代碼來源:permissions.class.php

示例12: getDeniedRecords

 /**
  *	Overload of the w2PObject::getDeniedRecords
  *	to ensure that the projects owned by denied companies are denied.
  *
  *	@author	handco <handco@sourceforge.net>
  *	@see	w2PObject::getAllowedRecords
  */
 public function getDeniedRecords($uid)
 {
     $aBuf1 = parent::getDeniedRecords($uid);
     $oCpy = new CCompany();
     // Retrieve which projects are allowed due to the company rules
     $aCpiesAllowed = $oCpy->getAllowedRecords($uid, 'company_id,company_name');
     //Department permissions
     $oDpt = new CDepartment();
     $aDptsAllowed = $oDpt->getAllowedRecords($uid, 'dept_id,dept_name');
     $q = new DBQuery();
     $q->addTable('projects');
     $q->addQuery('projects.project_id');
     $q->addJoin('project_departments', 'pd', 'pd.project_id = projects.project_id');
     if (count($aCpiesAllowed)) {
         if (array_search('0', $aCpiesAllowed) === false) {
             //If 0 (All Items of a module) are not permited then just add the allowed items only
             $q->addWhere('NOT (project_company IN (' . implode(',', array_keys($aCpiesAllowed)) . '))');
         } else {
             //If 0 (All Items of a module) are permited then don't add a where clause so the user is permitted to see all
         }
     } else {
         //if the user is not allowed any company then lets shut him off
         $q->addWhere('0=1');
     }
     if (count($aDptsAllowed)) {
         if (array_search('0', $aDptsAllowed) === false) {
             //If 0 (All Items of a module) are not permited then just add the allowed items only
             $q->addWhere('NOT (department_id IN (' . implode(',', array_keys($aDptsAllowed)) . '))');
         } else {
             //If 0 (All Items of a module) are permited then don't add a where clause so the user is permitted to see all
             $q->addWhere('NOT (department_id IS NULL)');
         }
     } else {
         //If 0 (All Items of a module) are permited then don't add a where clause so the user is permitted to see all
         $q->addWhere('NOT (department_id IS NULL)');
     }
     $aBuf2 = $q->loadColumn();
     $q->clear();
     return array_merge($aBuf1, $aBuf2);
 }
開發者ID:joly,項目名稱:web2project,代碼行數:47,代碼來源:projects.class.php

示例13: importTasks

 /**	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);
     $dateOffset = $destDate->dateDiff($origDate);
     // 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.
     foreach ($tasks as $task_id) {
         $newTask = new CTask();
         $newTask->load($task_id);
         if (in_array($task_id, $taskXref)) {
             // Fix task start date from project start date offset
             $origDate->setDate($newTask->task_start_date);
             $destDate->setDate($newTask->task_start_date);
             $destDate->addDays($dateOffset);
             $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($newTask->task_end_date);
                 $destDate->addDays($dateOffset);
                 $destDate = $destDate->next_working_day();
                 $newTask->task_end_date = $destDate->format(FMT_DATETIME_MYSQL);
             }
             $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
 }
開發者ID:klr2003,項目名稱:sourceread,代碼行數:84,代碼來源:projects.class.php

示例14: CFile

     // Now add any task reminders
     // If there wasn't a task, but there is one now, and
     // that task date is set, we need to set a reminder.
     if (empty($task_end_date) || !empty($end_date) && $task_end_date->dateDiff($end_date)) {
         $obj->addReminder();
     }
     // If there was a file that was attached to both the task, and the task
     // has moved projects, we need to move the file as well
     if ($move_files) {
         require_once $AppUI->getModuleClass('files');
         $filehandler = new CFile();
         $q = new DBQuery();
         $q->addTable('files', 'f');
         $q->addQuery('file_id');
         $q->addWhere('file_task = ' . (int) $obj->task_id);
         $files = $q->loadColumn();
         if (!empty($files)) {
             foreach ($files as $file) {
                 $filehandler->load($file);
                 $realname = $filehandler->file_real_filename;
                 $filehandler->file_project = $obj->task_project;
                 $filehandler->moveFile($move_files, $realname);
                 $filehandler->store();
             }
         }
     }
     $AppUI->setMsg($task_id ? 'Task updated' : 'Task added', UI_MSG_OK);
 }
 if (isset($hassign)) {
     $obj->updateAssigned($hassign, $hperc_assign_ar);
 }
開發者ID:srinivasulurao,項目名稱:jonel,代碼行數:31,代碼來源:do_task_aed.php

示例15: updateSubTasksProject

 /**
  * This function recursively updates all tasks project
  * to the one passed as parameter
  */
 public function updateSubTasksProject($new_project, $task_id = null)
 {
     $q = new DBQuery();
     if (is_null($task_id)) {
         $task_id = $this->task_id;
     }
     $q->addTable('tasks');
     $q->addQuery('task_id');
     $q->addWhere('task_parent = ' . (int) $task_id);
     $tasks_id = $q->loadColumn();
     $q->clear();
     if (count($tasks_id) == 0) {
         return true;
     }
     // update project of children
     $q->addTable('tasks');
     $q->addUpdate('task_project', $new_project);
     $q->addWhere('task_parent = ' . (int) $task_id);
     $q->exec();
     $q->clear();
     foreach ($tasks_id as $id) {
         if ($id != $task_id) {
             $this->updateSubTasksProject($new_project, $id);
         }
     }
 }
開發者ID:joly,項目名稱:web2project,代碼行數:30,代碼來源:tasks.class.php


注:本文中的DBQuery::loadColumn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。