コード例 #1
0
 function add_interested_party($data)
 {
     static $people;
     $data["emailAddress"] = str_replace(array("<", ">"), "", $data["emailAddress"]);
     // Add new entry
     $ip = new interestedParty();
     $existing = interestedParty::exists($data["entity"], $data["entityID"], $data["emailAddress"]);
     if ($existing) {
         $ip->set_id($existing["interestedPartyID"]);
         $ip->select();
     }
     $ip->set_value("entity", $data["entity"]);
     $ip->set_value("entityID", $data["entityID"]);
     $ip->set_value("fullName", $data["name"]);
     $ip->set_value("emailAddress", $data["emailAddress"]);
     $ip->set_value("interestedPartyActive", 1);
     if ($data["personID"]) {
         $ip->set_value("personID", $data["personID"]);
         $ip->set_value("fullName", person::get_fullname($data["personID"]));
     } else {
         $people or $people =& get_cached_table("person");
         foreach ($people as $personID => $p) {
             if ($data["emailAddress"] && same_email_address($p["emailAddress"], $data["emailAddress"])) {
                 $ip->set_value("personID", $personID);
                 $ip->set_value("fullName", $p["name"]);
             }
         }
     }
     $extra_interested_parties = config::get_config_item("defaultInterestedParties");
     if (!$ip->get_value("personID") && !in_array($data["emailAddress"], (array) $extra_interested_parties)) {
         $ip->set_value("external", 1);
         $q = prepare("SELECT * FROM clientContact WHERE clientContactEmail = '%s'", $data["emailAddress"]);
         $db = new db_alloc();
         $db->query($q);
         if ($row = $db->row()) {
             $ip->set_value("clientContactID", $row["clientContactID"]);
             $ip->set_value("fullName", $row["clientContactName"]);
         }
     }
     $ip->save();
     return $ip->get_id();
 }
コード例 #2
0
ファイル: comment.inc.php プロジェクト: cjbayliss/alloc
 function get_person_and_client($from_address, $from_name, $projectID = null)
 {
     $current_user =& singleton("current_user");
     $person = new person();
     $personID = $person->find_by_email($from_address);
     $personID or $personID = $person->find_by_name($from_name);
     if (!$personID) {
         $cc = new clientContact();
         $clientContactID = $cc->find_by_email($from_address);
         $clientContactID or $clientContactID = $cc->find_by_name($from_name, $projectID);
     }
     // If we don't have a $from_name, but we do have a personID or clientContactID, get proper $from_name
     if (!$from_name) {
         if ($personID) {
             $from_name = person::get_fullname($personID);
         } else {
             if ($clientContactID) {
                 $cc = new clientContact();
                 $cc->set_id($clientContactID);
                 $cc->select();
                 $from_name = $cc->get_value("clientContactName");
             } else {
                 $from_name = $from_address;
             }
         }
     }
     return array($personID, $clientContactID, $from_name);
 }
コード例 #3
0
ファイル: timeSheet.inc.php プロジェクト: cjbayliss/alloc
    function email_move_status_to_admin($direction, $info)
    {
        $current_user =& singleton("current_user");
        $project = $this->get_foreign_object("project");
        $projectManagers = $project->get_timeSheetRecipients();
        // Can get forwards to "admin" from "edit" and "manager"
        if ($direction == "forwards") {
            //3 ways to have permission to do this
            //project manager for the timesheet
            //no project manager and owner of the timesheet
            //the permission flag
            if (!(in_array($current_user->get_id(), $projectManagers) || empty($projectManagers) && $this->get_value("personID") == $current_user->get_id() || $this->have_perm(PERM_TIME_APPROVE_TIMESHEETS))) {
                //error, go away
                alloc_error("You do not have permission to change this timesheet.");
            }
            $db = new db_alloc();
            $hasItems = $db->qr("SELECT * FROM timeSheetItem WHERE timeSheetID = %d", $this->get_id());
            if (!$hasItems) {
                return alloc_error('Unable to submit time sheet, no items have been added.');
            }
            if ($this->get_value("status") == "manager") {
                $this->set_value("approvedByManagerPersonID", $current_user->get_id());
                $extra = " Approved By: " . person::get_fullname($current_user->get_id());
            }
            $this->set_value("status", "admin");
            $this->set_value("dateSubmittedToAdmin", date("Y-m-d"));
            $this->set_value("dateRejected", "");
            foreach ($info["timeSheetAdministrators"] as $adminID) {
                $email = array();
                $email["type"] = "timesheet_submit";
                $email["to"] = $info["people_cache"][$adminID]["emailAddress"];
                $email["subject"] = commentTemplate::populate_string(config::get_config_item("emailSubject_timeSheetToAdministrator"), "timeSheet", $this->get_id());
                $email["body"] = <<<EOD
    To Admin: {$info["admin_name"]}
  Time Sheet: {$info["url"]}
Submitted By: {$info["timeSheet_personID_name"]}
 For Project: {$info["projectName"]}
{$extra}

A timesheet has been submitted for your approval. If it is not
satisfactory, make it editable again for re-submission.

EOD;
                $this->get_value("billingNote") and $email["body"] .= "Billing Note: " . $this->get_value("billingNote");
                $msg[] = $this->shootEmail($email);
            }
            // Can get backwards to "admin" from "invoiced"
        } else {
            //requires INVOICE_TIMESHEETS
            if (!$this->have_perm(PERM_TIME_INVOICE_TIMESHEETS)) {
                //no permission, go away
                alloc_error("You do not have permission to change this timesheet.");
            }
            $this->set_value("approvedByAdminPersonID", "");
        }
        $this->set_value("status", "admin");
        return $msg;
    }
コード例 #4
0
ファイル: task.php プロジェクト: cjbayliss/alloc
            $task->delete();
            alloc_redirect($TPL["url_alloc_taskList"]);
        } else {
            alloc_error("This task cannot be deleted. You either don't have permission, or this task has history items.");
        }
    }
}
// Start stuff here
$task->set_values("task_");
$person = new person();
$person->set_id($task->get_value("creatorID"));
$person->select();
$TPL["task_createdBy"] = $person->get_name();
$TPL["task_createdBy_personID"] = $person->get_id();
if ($task->get_value("closerID") && $task->get_value("dateClosed")) {
    $TPL["task_closed_by"] = person::get_fullname($task->get_value("closerID"));
    $TPL["task_closed_when"] = $task->get_value("dateClosed");
}
$person = new person();
$person->set_id($task->get_value("personID"));
$person->select();
$TPL["person_username"] = $person->get_name();
$TPL["person_username_personID"] = $person->get_id();
$manager = new person();
$manager->set_id($task->get_value("managerID"));
$manager->select();
$TPL["manager_username"] = $manager->get_name();
$TPL["manager_username_personID"] = $manager->get_id();
$estimator = new person();
$estimator->set_id($task->get_value("estimatorID"));
$estimator->select();
コード例 #5
0
ファイル: calendar.php プロジェクト: cjbayliss/alloc
<?php

/*
 * Copyright (C) 2006-2011 Alex Lance, Clancy Malcolm, Cyber IT Solutions
 * Pty. Ltd.
 * 
 * This file is part of the allocPSA application <*****@*****.**>.
 * 
 * allocPSA is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at
 * your option) any later version.
 * 
 * allocPSA is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
 * License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with allocPSA. If not, see <http://www.gnu.org/licenses/>.
*/
require_once "../alloc.php";
function show_task_calendar_recursive()
{
    $calendar = new calendar(2, 20);
    $calendar->set_cal_person($_GET["personID"]);
    $calendar->set_return_mode("calendar");
    $calendar->draw();
}
$TPL["username"] = person::get_fullname($_GET["personID"]);
include_template("templates/taskCalendarM.tpl");
コード例 #6
0
ファイル: invoiceEntity.inc.php プロジェクト: cjbayliss/alloc
 function save_invoice_productSaleItems($invoiceID, $productSaleID)
 {
     $productSale = new productSale();
     $productSale->set_id($productSaleID);
     $productSale->select();
     $db = new db_alloc();
     $q = prepare("SELECT * FROM productSaleItem WHERE productSaleID = %d", $productSale->get_id());
     $q1 = $db->query($q);
     while ($row = $db->row($q1)) {
         $q = prepare("SELECT * FROM invoiceItem WHERE productSaleID = %d AND productSaleItemID = %d", $productSaleID, $row["productSaleItemID"]);
         $db = new db_alloc();
         $q2 = $db->query($q);
         $r2 = $db->row($q2);
         $ii = new invoiceItem();
         if ($r2) {
             $ii->set_id($r2["invoiceItemID"]);
         }
         $ii->currency = $row["sellPriceCurrencyTypeID"];
         $ii->set_value("invoiceID", $invoiceID);
         $ii->set_value("productSaleID", $productSale->get_id());
         $ii->set_value("productSaleItemID", $row["productSaleItemID"]);
         $ii->set_value("iiMemo", "Sale (" . $productSale->get_id() . ") item for " . person::get_fullname($productSale->get_value("personID")) . ", " . $row["description"]);
         $ii->set_value("iiQuantity", $row["quantity"]);
         $row["sellPrice"] = page::money($ii->currency, $row["sellPrice"] / $row["quantity"], "%mo");
         $ii->set_value("iiUnitPrice", $row["sellPrice"]);
         $ii->set_value("iiAmount", $row["sellPrice"] * $row["quantity"]);
         $d = $productSale->get_value("productSaleDate") or $d = $productSale->get_value("productSaleModifiedTime") or $d = $productSale->get_value("productSaleCreatedTime");
         $ii->set_value("iiDate", $d);
         //$ii->set_value("iiTax",config::get_config_item("taxPercent")); // product sale items are always excl GST
         $ii->save();
     }
 }
コード例 #7
0
 function populate_string($str, $entity, $entityID = false)
 {
     // Actually do the text substitution
     $current_user =& singleton("current_user");
     is_object($current_user) and $swap["cu"] = person::get_fullname($current_user->get_id());
     if ($entity == "timeSheet" && $entityID) {
         $timeSheet = new timeSheet();
         $timeSheet->set_id($entityID);
         $timeSheet->select();
         $timeSheet->load_pay_info();
         foreach ($timeSheet->pay_info as $k => $v) {
             $swap[$k] = $v;
         }
         if ($timeSheet->get_value("approvedByManagerPersonID")) {
             $swap["tm"] = person::get_fullname($timeSheet->get_value("approvedByManagerPersonID"));
         } else {
             $project = $timeSheet->get_foreign_object("project");
             $projectManagers = $project->get_timeSheetRecipients();
             if (is_array($projectManagers) && count($projectManagers)) {
                 $people =& get_cached_table("person");
                 foreach ($projectManagers as $pID) {
                     $swap["tm"] .= $commar . $people[$pID]["name"];
                     $commar = ", ";
                 }
             }
         }
         if ($timeSheet->get_value("approvedByAdminPersonID")) {
             $swap["tc"] = person::get_fullname($timeSheet->get_value("approvedByAdminPersonID"));
         } else {
             $people =& get_cached_table("person");
             $timeSheetAdministrators = config::get_config_item('defaultTimeSheetAdminList');
             if (count($timeSheetAdministrators)) {
                 $swap["tc"] = "";
                 $comma = "";
                 foreach ($timeSheetAdministrators as $adminID) {
                     $swap["tc"] .= $comma . $people[$adminID]["name"];
                     $comma = ", ";
                 }
             } else {
                 $swap["tc"] = 'no-one';
             }
         }
         $swap["ti"] = $timeSheet->get_id();
         $swap["to"] = person::get_fullname($timeSheet->get_value("personID"));
         $swap["ta"] = person::get_fullname($timeSheet->get_value("personID"));
         $swap["tf"] = $timeSheet->get_value("dateFrom");
         $swap["tt"] = $timeSheet->get_value("dateTo");
         $swap["ts"] = $timeSheet->get_timeSheet_status();
         $swap["tu"] = config::get_config_item("allocURL") . "time/timeSheet.php?timeSheetID=" . $timeSheet->get_id();
         $projectID = $timeSheet->get_value("projectID");
     }
     if ($entity == "task" && $entityID) {
         $task = new task();
         $task->set_id($entityID);
         $task->select();
         $swap["ti"] = $task->get_id();
         $swap["to"] = person::get_fullname($task->get_value("creatorID"));
         $swap["ta"] = person::get_fullname($task->get_value("personID"));
         $swap["tm"] = person::get_fullname($task->get_value("managerID"));
         $swap["tc"] = person::get_fullname($task->get_value("closerID"));
         $swap["tn"] = $task->get_value("taskName");
         $swap["td"] = $task->get_value("taskDescription");
         $swap["tu"] = config::get_config_item("allocURL") . "task/task.php?taskID=" . $task->get_id();
         $swap["tp"] = $task->get_priority_label();
         $swap["ts"] = $task->get_task_status("label");
         $swap["teb"] = $task->get_value("timeBest");
         $swap["tem"] = $task->get_value("timeExpected");
         $swap["tew"] = $task->get_value("timeWorst");
         $swap["tep"] = person::get_fullname($task->get_value("estimatorID"));
         //time estimate person, when it's implemented
         $projectID = $task->get_value("projectID");
     }
     if ($entity == "project" && $entityID || $projectID) {
         $project = new project();
         if ($projectID) {
             $project->set_id($projectID);
         } else {
             $project->set_id($entityID);
         }
         $project->select();
         $swap["pn"] = $project->get_value("projectName");
         $swap["pi"] = $project->get_id();
         $clientID = $project->get_value("clientID");
     }
     if ($entity == "client" && $entityID || $clientID) {
         $client = new client();
         if ($clientID) {
             $client->set_id($clientID);
         } else {
             $client->set_id($entityID);
         }
         $client->select();
         $swap["li"] = $client->get_id();
         $swap["cc"] = $client->get_value("clientName");
     }
     $swap["cd"] = config::get_config_item("companyContactAddress");
     $swap["cd"] .= " " . config::get_config_item("companyContactAddress2");
     $swap["cd"] .= " " . config::get_config_item("companyContactAddress3");
     $swap["cd"] .= "\nP: " . config::get_config_item("companyContactPhone");
     $swap["cd"] .= "\nF: " . config::get_config_item("companyContactFax");
     $swap["cd"] .= "\nE: " . config::get_config_item("companyContactEmail");
     $swap["cd"] .= "\nW: " . config::get_config_item("companyContactHomePage");
     $swap["cn"] = config::get_config_item("companyName");
     $swap["c1"] = config::get_config_item("companyContactAddress");
     $swap["c2"] = config::get_config_item("companyContactAddress2");
     $swap["c3"] = config::get_config_item("companyContactAddress3");
     $swap["ce"] = config::get_config_item("companyContactEmail");
     $swap["cp"] = config::get_config_item("companyContactPhone");
     $swap["cf"] = config::get_config_item("companyContactFax");
     $swap["cw"] = config::get_config_item("companyContactHomePage");
     foreach ($swap as $k => $v) {
         $str = str_replace("%" . $k, $v, $str);
     }
     return $str;
 }
コード例 #8
0
ファイル: project.php プロジェクト: cjbayliss/alloc
function show_projectPerson_list()
{
    global $db;
    global $TPL;
    global $projectID;
    $template = "templates/projectPersonSummaryViewR.tpl";
    if ($projectID) {
        $query = prepare("SELECT personID, roleName\n                          FROM projectPerson\n                     LEFT JOIN role ON role.roleID = projectPerson.roleID\n                         WHERE projectID = %d \n                      GROUP BY projectPerson.personID\n                      ORDER BY roleSequence DESC, personID ASC", $projectID);
        $db->query($query);
        while ($db->next_record()) {
            $projectPerson = new projectPerson();
            $projectPerson->read_db_record($db);
            $TPL['person_roleName'] = $db->f("roleName");
            $TPL['person_name'] = person::get_fullname($projectPerson->get_value('personID'));
            include_template($template);
        }
    }
}
コード例 #9
0
ファイル: import_export.inc.php プロジェクト: cjbayliss/alloc
function export_gnome_planner($projectID)
{
    $project = new project();
    $project->set_id($projectID);
    $project->select();
    // Note: DOM_Document is a wrapper that wraps DOMDocument for PHP5 and DomDocument for PHP4
    $doc = get_xml_document();
    $doc->load(ALLOC_MOD_DIR . "shared" . DIRECTORY_SEPARATOR . "export_templates" . DIRECTORY_SEPARATOR . "template.planner");
    // General metadata
    $rootNode = $doc->getElementsByTagName("project");
    $rootNode = $rootNode->item(0);
    $rootNode->setAttribute("company", config::get_config_item("companyName"));
    // Get the project manager
    $projectManager = $project->get_project_manager();
    $rootNode->setAttribute("manager", person::get_fullname($projectManager[0]));
    $rootNode->setAttribute("name", $project->get_value("projectName"));
    if ($project->get_value("dateActualStart")) {
        $projectStartDate = export_planner_date(planner_date_timestamp($project->get_value("dateActualStart")));
    } else {
        $projectStartDate = export_planner_date(planner_date_timestamp($project->get_value("dateTargetStart")));
    }
    $rootNode->setAttribute("project-start", $projectStartDate);
    $resourcesUsed = array();
    // Export all tasks in the project
    $taskOptions["projectIDs"] = array($project->get_id());
    $taskOptions["return"] = "array";
    $taskOptions["taskView"] = "byProject";
    $tasks = task::get_list($taskOptions);
    // We need to sort by taskID (we assume taskIDs were assigned linearly on import) otherwise Planner will get very confused with ordering
    foreach ($tasks as $task) {
        $taskIDs[] = $task['taskID'];
    }
    array_multisort($taskIDs, $tasks);
    $taskRootNode = $doc->getElementsByTagName("tasks");
    $taskRootNode = $taskRootNode->item(0);
    foreach ($tasks as $task) {
        $taskNode = $doc->createElement("task");
        // Use the alloc internal ID rather than pointlessly renumbering things
        $taskNode->setAttribute("id", $task["taskID"]);
        $taskNode->setAttribute("name", $task["taskName"]);
        $taskNode->setAttribute("note", $task["taskDescription"]);
        // Ugly date handling
        if (!$task["dateActualStart"]) {
            if (!$task["dateTargetStart"]) {
                // This is a reasonably bad situation
                $taskStartDate = time();
            } else {
                $taskStartDate = planner_date_timestamp($task["dateTargetStart"]);
            }
        } else {
            $taskStartDate = planner_date_timestamp($task["dateActualStart"]);
        }
        if (!$task["dateActualCompletion"]) {
            if (!$task["dateTargetCompletion"]) {
                //The task has to last for some amount of time, so end = start (otherwise we get end = 1970)
                $taskEndDate = $taskStartDate;
            } else {
                $taskEndDate = planner_date_timestamp($task["dateTargetCompletion"]);
            }
        } else {
            $taskEndDate = planner_date_timestamp($task["dateActualCompletion"]);
        }
        // Take a stab at the duration we need to give this task
        $taskDuration = $taskEndDate - $taskStartDate;
        // That's the total number of seconds, Planner expects the number of 8-hour days worth of seconds
        $taskDuration = $taskDuration / 86400 * 28800;
        // note: the above doesn't account for weekends so there is a discrepancy between task durations in alloc and those in Planner, the solution is to make people work on the weekends
        $taskNode->setAttribute("work", $taskDuration);
        $taskNode->setAttribute("start", export_planner_date($taskStartDate));
        $taskNode->setAttribute("work-start", export_planner_date($taskStartDate));
        $taskNode->setAttribute("end", export_planner_date($taskEndDate));
        $taskNode->setAttribute("scheduling", "fixed-work");
        $constraintNode = $doc->createElement("constraint");
        $constraintNode->setAttribute("type", "start-no-earlier-than");
        $constraintNode->setAttribute("time", export_planner_date($taskStartDate));
        $taskNode->appendChild($constraintNode);
        if ($task["taskTypeID"] == "Milestone") {
            $taskNode->setAttribute("type", "milestone");
        }
        $resourcesUsed[$task["taskID"]] = $task['personID'];
        $taskRootNode->appendChild($taskNode);
    }
    // Now do the resources and their linkage to tasks
    $resourcesRootNode = $doc->getElementsByTagName("resources");
    $resourcesRootNode = $resourcesRootNode->item(0);
    $allocationsRootNode = $doc->getElementsByTagName("allocations");
    $allocationsRootNode = $allocationsRootNode->item(0);
    $resources = array();
    //Store the users that need to be added to <resources>
    foreach ($resourcesUsed as $taskID => $resourceID) {
        if (isset($resources[$resourceID])) {
            $person = $resources[$resourceID];
        } else {
            $person = new person();
            $person->set_id($resourceID);
            $person->select();
            $resources[$resourceID] = $person;
            // Add this person to <resources>
            $resourceNode = $doc->createElement("resource");
            $resourceNode->setAttribute("id", $person->get_id());
            $resourceNode->setAttribute("name", $person->get_value("firstName") . " " . $person->get_value("surname"));
            $resourceNode->setAttribute("short-name", $person->get_value("username"));
            $resourceNode->setAttribute("email", $person->get_value("emailAddress"));
            $resourceNode->setAttribute("units", "0");
            $resourceNode->setAttribute("type", "1");
            //1 means "Work" (the other option being Materials)
            $resourcesRootNode->appendChild($resourceNode);
        }
        //Now the actual allocation
        $allocationNode = $doc->createElement("allocation");
        //Units means "percentage working on this" for which alloc has no analgoue
        $allocationNode->setAttribute("units", "100");
        $allocationNode->setAttribute("task-id", $taskID);
        $allocationNode->setAttribute("resource-id", $resourceID);
        $allocationsRootNode->appendChild($allocationNode);
    }
    return $doc->saveXML();
}
コード例 #10
0
ファイル: transaction.php プロジェクト: cjbayliss/alloc
$TPL["statusOptions"] = page::select_options(array("pending" => "Pending", "rejected" => "Rejected", "approved" => "Approved"), $transaction->get_value("status"));
$transactionTypes = transaction::get_transactionTypes();
$TPL["transactionTypeOptions"] = page::select_options($transactionTypes, $transaction->get_value("transactionType"));
is_object($transaction) and $TPL["transactionTypeLink"] = $transaction->get_transaction_type_link();
$db = new db_alloc();
$tf = new tf();
$options = $tf->get_assoc_array("tfID", "tfName");
// Special cases for the current tfID and fromTfID
$options = add_tf($transaction->get_value("tfID"), $options, "tfIDWarning", " (warning: the TF <b>%s</b> is currently inactive)");
$options = add_tf($transaction->get_value("fromTfID"), $options, "fromTfIDWarning", " (warning: the TF <b>%s</b> is currently inactive)");
$TPL["tfIDOptions"] = page::select_options($options, $transaction->get_value("tfID"));
$TPL["fromTfIDOptions"] = page::select_options($options, $transaction->get_value("fromTfID"));
$q = "SELECT projectID as value, projectName as label FROM project WHERE projectStatus = 'Current' ORDER BY projectName";
$TPL["projectIDOptions"] = page::select_options($q, $transaction->get_value("projectID"));
$TPL["transactionModifiedUser"] = page::htmlentities(person::get_fullname($TPL["transactionModifiedUser"]));
$TPL["transactionCreatedUser"] = page::htmlentities(person::get_fullname($TPL["transactionCreatedUser"]));
$tf1 = new tf();
$tf1->set_id($TPL["tfID"]);
$tf1->select();
$TPL["tf_link"] = $tf1->get_link();
$tf2 = new tf();
$tf2->set_id($TPL["fromTfID"]);
$tf2->select();
$TPL["from_tf_link"] = $tf2->get_link();
$p = $transaction->get_foreign_object("project");
$TPL["project_link"] = $p->get_link();
$TPL["taxName"] = config::get_config_item("taxName");
if (is_object($current_user) && !$current_user->have_role("admin") && is_object($transaction) && in_array($transaction->get_value("status"), array("approved", "rejected"))) {
    $TPL["main_alloc_title"] = "View Transaction - " . APPLICATION_NAME;
    include_template("templates/viewTransactionM.tpl");
} else {
コード例 #11
0
ファイル: invoice.php プロジェクト: cjbayliss/alloc
function show_new_invoiceItem($template)
{
    global $TPL;
    global $invoice;
    global $invoiceID;
    $current_user =& singleton("current_user");
    // Don't show entry form if no ID
    if (!$invoiceID) {
        return;
    }
    $TPL["div1"] = "";
    $TPL["div2"] = " class=\"hidden\"";
    $TPL["div3"] = " class=\"hidden\"";
    $TPL["div4"] = " class=\"hidden\"";
    if (is_object($invoice) && $invoice->get_value("invoiceStatus") == 'edit' && $current_user->have_role('admin')) {
        // If we are editing an existing invoiceItem
        if (is_array($_POST["invoiceItem_edit"])) {
            $invoiceItemID = key($_POST["invoiceItem_edit"]);
            $invoiceItem = new invoiceItem();
            $invoiceItem->currency = $invoice->get_value("currencyTypeID");
            $invoiceItem->set_id($invoiceItemID);
            $invoiceItem->select();
            $invoiceItem->set_tpl_values("invoiceItem_");
            $TPL["invoiceItem_buttons"] = '
        <button type="submit" name="invoiceItem_delete[' . $invoiceItemID . ']" value="1" class="delete_button">Delete<i class="icon-trash"></i></button>
        <button type="submit" name="invoiceItem_save[' . $invoiceItemID . ']" value="1" class="save_button">Save Item<i class="icon-edit"></i></button>
      ';
            if ($invoiceItem->get_value("timeSheetID")) {
                unset($TPL["div2"]);
                $TPL["div1"] = " class=\"hidden\"";
                $TPL["sbs_link"] = "timeSheet_ii";
            } else {
                if ($invoiceItem->get_value("expenseFormID")) {
                    unset($TPL["div3"]);
                    $TPL["div1"] = " class=\"hidden\"";
                    $TPL["sbs_link"] = "expenseForm_ii";
                } else {
                    if ($invoiceItem->get_value("productSaleID")) {
                        unset($TPL["div4"]);
                        $TPL["div1"] = " class=\"hidden\"";
                        $TPL["sbs_link"] = "productSale_ii";
                    }
                }
            }
            // Else default values for creating a new invoiceItem
        } else {
            $invoiceItem = new invoiceItem();
            $invoiceItem->set_values("invoiceItem_");
            $TPL["invoiceItem_buttons"] = '
         <button type="submit" name="invoiceItem_save" value="1" class="save_button">Add Item<i class="icon-plus-sign"></i></button>
      ';
        }
        // Build dropdown lists for timeSheet and expenseForm options.
        if ($invoice->get_value("clientID")) {
            // Time Sheet dropdown
            $db = new db_alloc();
            $q = prepare("SELECT projectID FROM project WHERE clientID = %d", $invoice->get_value("clientID"));
            $db->query($q);
            $projectIDs = array();
            while ($row = $db->row()) {
                $projectIDs[] = $row["projectID"];
            }
            if ($projectIDs) {
                $q = prepare("SELECT timeSheet.*, project.projectName \n                        FROM timeSheet\n                   LEFT JOIN project ON project.projectID = timeSheet.projectID \n                       WHERE timeSheet.projectID IN (%s) \n                         AND timeSheet.status != 'finished'\n                    GROUP BY timeSheet.timeSheetID\n                    ORDER BY timeSheetID\n                     ", $projectIDs);
                $db->query($q);
                $timeSheetStatii = timeSheet::get_timeSheet_statii();
                while ($row = $db->row()) {
                    $t = new timeSheet();
                    $t->read_db_record($db);
                    $t->load_pay_info();
                    $dollars = $t->pay_info["total_customerBilledDollars"] or $dollars = $t->pay_info["total_dollars"];
                    $timeSheetOptions[$row["timeSheetID"]] = "Time Sheet #" . $t->get_id() . " " . $row["dateFrom"] . " " . $dollars . " for " . person::get_fullname($row["personID"]) . ", Project: " . $row["projectName"] . " [" . $timeSheetStatii[$t->get_value("status")] . "]";
                }
                $TPL["timeSheetOptions"] = page::select_options($timeSheetOptions, $invoiceItem->get_value("timeSheetID"), 150);
            }
            // Expense Form dropdown
            $db = new db_alloc();
            $q = prepare("SELECT expenseFormID, expenseFormCreatedUser\n                      FROM expenseForm \n                     WHERE expenseFormFinalised = 1 \n                       AND seekClientReimbursement = 1\n                       AND clientID = %d\n                  ORDER BY expenseForm.expenseFormCreatedTime", $invoice->get_value("clientID"));
            $db->query($q);
            while ($row = $db->row()) {
                $expenseFormOptions[$row["expenseFormID"]] = "Expense Form #" . $row["expenseFormID"] . " " . page::money(config::get_config_item("currency"), expenseForm::get_abs_sum_transactions($row["expenseFormID"]), "%s%m %c") . " " . person::get_fullname($row["expenseFormCreatedUser"]);
            }
            if ($invoiceItem->get_value("expenseFormID")) {
                $id = $invoiceItem->get_value("expenseFormID");
            }
            $TPL["expenseFormOptions"] = page::select_options($expenseFormOptions, $id, 90);
            $q = prepare("SELECT *\n                      FROM productSale\n                     WHERE clientID = %d\n                       AND status = 'admin'\n                   ", $invoice->get_value("clientID"));
            $invoice->get_value("projectID") and $q .= prepare(" AND projectID = %d", $invoice->get_value("projectID"));
            $db->query($q);
            while ($row = $db->row()) {
                $productSale = new productSale();
                $productSale->set_id($row["productSaleID"]);
                $productSale->select();
                $ps_row = $productSale->get_amounts();
                $productSaleOptions[$row["productSaleID"]] = "Sale #" . $row["productSaleID"] . " " . $ps_row["total_sellPrice"] . " " . person::get_fullname($row["personID"]);
            }
            if ($invoiceItem->get_value("productSaleID")) {
                $id = $invoiceItem->get_value("productSaleID");
            }
            $TPL["productSaleOptions"] = page::select_options($productSaleOptions, $id, 90);
        }
        $TPL["invoiceItem_iiQuantity"] or $TPL["invoiceItem_iiQuantity"] = 1;
        $TPL["invoiceItem_invoiceID"] = $invoice->get_id();
        include_template($template);
    }
}
コード例 #12
0
ファイル: productSale.php プロジェクト: cjbayliss/alloc
$TPL["productSaleID"] = $productSale->get_id();
$showCosts = $_POST["showCosts"] or $_showCosts = $_GET["showCosts"];
$productSale->set_values();
list($client_select, $client_link, $project_select, $project_link) = client::get_client_and_project_dropdowns_and_links($clientID, $projectID);
$TPL["show_client_options"] = $client_link;
$TPL["show_project_options"] = $project_link;
$tf = new tf();
if ($productSale->get_value("tfID")) {
    $tf->set_id($productSale->get_value("tfID"));
    $tf->select();
    $TPL["show_tf_options"] = $tf->get_link();
    $tf_sel = $productSale->get_value("tfID");
}
$tf_sel or $tf_sel = config::get_config_item("mainTfID");
$tf_select = "<select name='tfID'>" . page::select_options($tflist, $tf_sel) . "</select>";
$TPL["show_person_options"] = person::get_fullname($productSale->get_value("personID"));
$TPL["show_date"] = $productSale->get_value("productSaleDate");
$TPL["show_extRef"] = $productSale->get_value("extRef");
$TPL["show_extRefDate"] = $productSale->get_value("extRefDate");
if (!$productSale->get_id() || $productSale->get_value("status") != "finished" && !($productSale->get_value("status") == "admin" && !CAN_APPROVE_TRANSACTIONS)) {
    $TPL["show_client_options"] = $client_select;
    $TPL["show_project_options"] = $project_select;
    $TPL["show_tf_options"] = $tf_select;
    $personID = $productSale->get_value("personID") or $personID = $current_user->get_id();
    $TPL["show_person_options"] = "<select name='personID'>" . page::select_options(person::get_username_list($personID), $personID) . "</select>";
    $TPL["show_date"] = page::calendar("productSaleDate", $productSale->get_value("productSaleDate"));
    $TPL["show_extRef"] = "<input type='text' name='extRef' value='" . $productSale->get_value("extRef") . "' size='10'>";
    $TPL["show_extRefDate"] = page::calendar("extRefDate", $productSale->get_value("extRefDate"));
}
$TPL["productSale_status"] = $productSale->get_value("status");
$amounts = $productSale->get_amounts();
コード例 #13
0
ファイル: calendar.inc.php プロジェクト: cjbayliss/alloc
 function draw()
 {
     global $TPL;
     $this->draw_canvas();
     $this->draw_row_header();
     $this->draw_body();
     $i = -7;
     while (date("D", mktime(0, 0, 0, date("m"), date("d") + $i, date("Y"))) != $this->first_day_of_week) {
         $i++;
     }
     $i = $i - $this->week_start * 7;
     $sunday_day = date("d", mktime(0, 0, 0, date("m"), date("d") + $i, date("Y")));
     $sunday_month = date("m", mktime(0, 0, 0, date("m"), date("d") + $i, date("Y")));
     $sunday_year = date("Y", mktime(0, 0, 0, date("m"), date("d") + $i, date("Y")));
     $i = 0;
     $absences = $this->get_cal_absences();
     $reminders = $this->get_cal_reminders();
     $tasks_to_start = $this->get_cal_tasks_to_start();
     $tasks_to_complete = $this->get_cal_tasks_to_complete();
     // For each single week...
     while ($i < $this->weeks_to_display) {
         $this->draw_row();
         $a = 0;
         while ($a < 7) {
             $dates_of_week[$this->days_of_week[$a]] = date("Y-m-d", mktime(0, 0, 0, $sunday_month, $sunday_day + 7 * $i + $a, $sunday_year));
             $a++;
         }
         foreach ($dates_of_week as $day => $date) {
             $d = new calendar_day();
             #$d->set_date(date("Y-m-d", mktime(0, 0, 0, $sunday_month, $sunday_day + (7 * $i + $k), $sunday_year));
             $d->set_date($date);
             $d->set_links($this->get_link_new_task($date) . $this->get_link_new_reminder($date) . $this->get_link_new_absence($date));
             // Tasks to be Started
             $tasks_to_start[$date] or $tasks_to_start[$date] = array();
             foreach ($tasks_to_start[$date] as $t) {
                 unset($extra);
                 $t["timeLimit"] and $extra = " (" . sprintf("Limit %0.1fhrs", $t["timeLimit"]) . ")";
                 $d->start_tasks[] = '<a href="' . $TPL["url_alloc_task"] . 'taskID=' . $t["taskID"] . '">' . page::htmlentities($t["taskName"] . $extra) . "</a>";
             }
             // Tasks to be Completed
             $tasks_to_complete[$date] or $tasks_to_complete[$date] = array();
             foreach ($tasks_to_complete[$date] as $t) {
                 unset($extra);
                 $t["timeLimit"] and $extra = " (" . sprintf("Limit %0.1fhrs", $t["timeLimit"]) . ")";
                 $d->complete_tasks[] = '<a href="' . $TPL["url_alloc_task"] . 'taskID=' . $t["taskID"] . '">' . page::htmlentities($t["taskName"] . $extra) . "</a>";
             }
             // Reminders
             $reminders[$date] or $reminders[$date] = array();
             foreach ($reminders[$date] as $r) {
                 #if (date("Y-m-d",$r["reminderTime"]) == $date) {
                 unset($wrap_start, $wrap_end);
                 if (!$r["reminderActive"]) {
                     $wrap_start = "<strike>";
                     $wrap_end = "</strike>";
                 }
                 $text = page::htmlentities($r["reminderSubject"]);
                 $r["reminderTime"] and $text = date("g:ia", $r["reminderTime"]) . " " . $text;
                 $d->reminders[] = '<a href="' . $TPL["url_alloc_reminder"] . '&step=3&reminderID=' . $r["reminderID"] . '&returnToParent=' . $this->rtp . '&personID=' . $r["personID"] . '">' . $wrap_start . $text . $wrap_end . '</a>';
                 #}
             }
             // Absences
             $absences[$date] or $absences[$date] = array();
             foreach ($absences[$date] as $a) {
                 $d->absences[] = '<a href="' . $TPL["url_alloc_absence"] . 'absenceID=' . $a["absenceID"] . '&returnToParent=' . $this->rtp . '">' . person::get_fullname($a["personID"]) . ': ' . page::htmlentities($a["absenceType"]) . '</a>';
             }
             $d->draw_day_html();
             $k++;
         }
         $i++;
         $this->draw_row_end();
     }
     $this->draw_body_end();
     $this->draw_canvas_end();
 }
コード例 #14
0
ファイル: expenseForm.inc.php プロジェクト: cjbayliss/alloc
 function get_pending_repeat_transaction_list()
 {
     global $TPL;
     $transactionTypes = transaction::get_transactionTypes();
     $q = "SELECT * FROM transaction \n              LEFT JOIN transactionRepeat on transactionRepeat.transactionRepeatID = transaction.transactionRepeatID \n                  WHERE transaction.transactionRepeatID IS NOT NULL AND transaction.status = 'pending'";
     $db = new db_alloc();
     $db->query($q);
     while ($row = $db->row()) {
         $transaction = new transaction();
         $transaction->read_db_record($db);
         $transaction->set_values();
         $transactionRepeat = new transactionRepeat();
         $transactionRepeat->read_db_record($db);
         $transactionRepeat->set_values();
         $row["transactionType"] = $transactionTypes[$transaction->get_value("transactionType")];
         $row["formTotal"] = $db->f("amount");
         $row["transactionModifiedTime"] = $transaction->get_value("transactionModifiedTime");
         $row["transactionCreatedTime"] = $transaction->get_value("transactionCreatedTime");
         $row["transactionCreatedUser"] = person::get_fullname($transaction->get_value("transactionCreatedUser"));
         $rows[] = $row;
     }
     return (array) $rows;
 }
コード例 #15
0
ファイル: tf.php プロジェクト: cjbayliss/alloc
        exit;
    }
}
if ($_POST["person_save"] || $_POST["person_delete"]) {
    $tfPerson = new tfPerson();
    $tfPerson->read_globals();
    $tfPerson->read_globals("person_");
    if (!$_POST["person_personID"]) {
        alloc_error("Please select a person from the dropdown list.");
    } else {
        if ($_POST["person_save"]) {
            $tfPerson->save();
            $TPL["message_good"][] = "Person added to TF.";
        } else {
            if ($_POST["person_delete"]) {
                $tfPerson->delete();
            }
        }
    }
}
$tf->set_values();
$TPL["tfModifiedTime"] = $tf->get_value("tfModifiedTime");
if ($tf->get_value("tfModifiedUser")) {
    $TPL["tfModifiedUser"] = person::get_fullname($tf->get_value("tfModifiedUser"));
}
$tf->get_value("tfActive") || !$tf->get_id() and $TPL["tfIsActive"] = " checked";
$TPL["main_alloc_title"] = "Edit TF - " . APPLICATION_NAME;
if (!$tf->get_id()) {
    $TPL["message_help"][] = "Enter the details below and click the Save button to create a new Tagged Fund. \n                            <br><br>A Tagged Fund or TF, is like a sort of bank account within allocPSA. \n                            It contains transactions which track the transfer of monies.";
}
include_template("templates/tfM.tpl");