Beispiel #1
0
 function get_link($row = array())
 {
     global $TPL;
     if (is_object($this)) {
         return "<a href=\"" . $TPL["url_alloc_product"] . "productID=" . $this->get_id() . "\">" . $this->get_value("productName", DST_HTML_DISPLAY) . "</a>";
     } else {
         return "<a href=\"" . $TPL["url_alloc_product"] . "productID=" . $row["productID"] . "\">" . page::htmlentities($row["productName"]) . "</a>";
     }
 }
Beispiel #2
0
function show_productSale_list($productSaleID, $template)
{
    global $TPL;
    global $productSaleItemsDoExist;
    $productSale = new productSale();
    $productSale->set_id($productSaleID);
    $productSale->select();
    $productSale->set_tpl_values();
    $taxName = config::get_config_item("taxName");
    $product = new product();
    $ops = $product->get_assoc_array("productID", "productName");
    $query = prepare("SELECT *\n                      FROM productSaleItem \n                     WHERE productSaleID = %d", $productSaleID);
    $db = new db_alloc();
    $db->query($query);
    while ($db->next_record()) {
        $productSaleItemsDoExist = true;
        $productSaleItem = new productSaleItem();
        $productSaleItem->read_db_record($db);
        $productSaleItem->set_tpl_values();
        $TPL["itemSellPrice"] = $productSaleItem->get_value("sellPrice");
        $TPL["itemMargin"] = $productSaleItem->get_amount_margin();
        $TPL["itemSpent"] = $productSaleItem->get_amount_spent();
        $TPL["itemEarnt"] = $productSaleItem->get_amount_earnt();
        $TPL["itemOther"] = $productSaleItem->get_amount_other();
        $TPL["itemCosts"] = page::money(config::get_config_item("currency"), product::get_buy_cost($productSaleItem->get_value("productID")) * $productSaleItem->get_value("quantity"), "%s%mo %c");
        $TPL["itemTotalUnallocated"] = $productSaleItem->get_amount_unallocated();
        $TPL["productList_dropdown"] = page::select_options($ops, $productSaleItem->get_value("productID"));
        $TPL["productLink"] = "<a href=\"" . $TPL["url_alloc_product"] . "productID=" . $productSaleItem->get_value("productID") . "\">" . page::htmlentities($ops[$productSaleItem->get_value("productID")]) . "</a>";
        $TPL["transactions"] = $productSale->get_transactions($productSaleItem->get_id());
        if ($taxName) {
            $TPL["sellPriceTax_check"] = sprintf(" <input type='checkbox' name='sellPriceIncTax[]' value='%d'%s> inc %s", $productSaleItem->get_id(), $productSaleItem->get_value("sellPriceIncTax") ? ' checked' : '', $taxName);
            $TPL["sellPriceTax_label"] = $productSaleItem->get_value("sellPriceIncTax") ? " inc " . $taxName : " ex " . $taxName;
        }
        include_template($template);
    }
}
Beispiel #3
0
 public static function get_list($_FORM)
 {
     $current_user =& singleton("current_user");
     global $TPL;
     /*
      * This is the definitive method of getting a list of transactions that need a sophisticated level of filtering
      *
      */
     $_FORM["tfIDs"] = transaction::reduce_tfs($_FORM);
     // Non-admin users must specify a valid TF
     if (!$current_user->have_role("admin") && !$_FORM["tfIDs"]) {
         return;
     }
     $filter = transaction::get_list_filter($_FORM);
     $debug = $_FORM["debug"];
     $debug and print "\n<pre>_FORM: " . print_r($_FORM, 1) . "</pre>";
     $debug and print "\n<pre>filter: " . print_r($filter, 1) . "</pre>";
     $_FORM["return"] or $_FORM["return"] = "html";
     $filter["prevBalance"] and $filter2[] = $filter["prevBalance"];
     $filter["tfIDs"] and $filter2[] = $filter["tfIDs"];
     $filter2 and $filter2[] = " (status = 'approved') ";
     unset($filter["prevBalance"]);
     if (is_array($filter2) && count($filter2)) {
         $filter2 = " WHERE " . implode(" AND ", $filter2);
     }
     if (is_array($filter) && count($filter)) {
         $filter = " WHERE " . implode(" AND ", $filter);
     }
     $_FORM["sortTransactions"] or $_FORM["sortTransactions"] = "transactionDate";
     $order_by = "ORDER BY " . $_FORM["sortTransactions"];
     // Determine opening balance
     if (is_array($_FORM['tfIDs']) && count($_FORM['tfIDs'])) {
         $q = prepare("SELECT SUM( IF(fromTfID IN (%s),-amount,amount) * pow(10,-currencyType.numberToBasic) * exchangeRate) AS balance\n                      FROM transaction \n                 LEFT JOIN currencyType ON currencyType.currencyTypeID = transaction.currencyTypeID\n                    " . $filter2, $_FORM['tfIDs']);
         $debug and print "\n<br>QUERY: " . $q;
         $db = new db_alloc();
         $db->query($q);
         $db->row();
         $_FORM["opening_balance"] = $db->f("balance");
         $running_balance = $db->f("balance");
     }
     $q = "SELECT *, \n                 (amount * pow(10,-currencyType.numberToBasic)) as amount1,\n                 (amount * pow(10,-currencyType.numberToBasic) * exchangeRate) as amount2,\n                 if(transactionModifiedTime,transactionModifiedTime,transactionCreatedTime) AS transactionSortDate,\n                 tf1.tfName as fromTfName,\n                 tf2.tfName as tfName\n            FROM transaction \n       LEFT JOIN currencyType ON currencyType.currencyTypeID = transaction.currencyTypeID\n       LEFT JOIN tf tf1 ON transaction.fromTfID = tf1.tfID\n       LEFT JOIN tf tf2 ON transaction.tfID = tf2.tfID\n         " . $filter . " \n         " . $order_by;
     $debug and print "\n<br>QUERY2: " . $q;
     $db = new db_alloc();
     $db->query($q);
     $for_cyber = config::for_cyber();
     while ($row = $db->next_record()) {
         #echo "<pre>".print_r($row,1)."</pre>";
         $i++;
         $t = new transaction();
         if (!$t->read_db_record($db)) {
             continue;
         }
         $print = true;
         // If the destination of this TF is not the current TfID, then invert the $amount
         $amount = $row["amount2"];
         if (!in_array($row["tfID"], (array) $_FORM["tfIDs"])) {
             $amount = -$amount;
             $row["amount1"] = -$row["amount1"];
         }
         $row["amount"] = $amount;
         $row["transactionURL"] = $t->get_url();
         $row["transactionName"] = $t->get_name($_FORM);
         $row["transactionLink"] = $t->get_transaction_link($_FORM);
         $row["transactionTypeLink"] = $t->get_transaction_type_link() or $row["transactionTypeLink"] = $row["transactionType"];
         $row["transactionSortDate"] = format_date("Y-m-d", $row["transactionSortDate"]);
         $row["fromTfIDLink"] = "<a href=\"" . $TPL["url_alloc_transactionList"] . "tfID=" . $row["fromTfID"] . "\">" . page::htmlentities($row["fromTfName"]) . "</a>";
         $row["tfIDLink"] = "<a href=\"" . $TPL["url_alloc_transactionList"] . "tfID=" . $row["tfID"] . "\">" . page::htmlentities($row["tfName"]) . "</a>";
         if ($t->get_value("status") == "approved") {
             $running_balance += $amount;
             $row["running_balance"] = page::money(config::get_config_item("currency"), $running_balance, "%m %c");
         }
         if ($amount > 0) {
             $row["amount_positive"] = page::money($row["currencyTypeID"], $row["amount1"], "%m %c");
             $total_amount_positive += $amount;
         } else {
             $row["amount_negative"] = page::money($row["currencyTypeID"], $row["amount1"], "%m %c");
             $total_amount_negative += $amount;
         }
         // Cyber only hackery for ext ref field on product sales
         if ($for_cyber && $row["productSaleID"]) {
             $ps = new productSale();
             $ps->set_id($row["productSaleID"]);
             if ($ps->select()) {
                 $ps->get_value("extRef") and $row["product"] .= " (Ext ref: " . $ps->get_value("extRef") . ")";
             }
         }
         $transactions[$row["transactionID"]] = $row;
     }
     $_FORM["total_amount_positive"] = page::money(config::get_config_item("currency"), $total_amount_positive, "%s%m %c");
     $_FORM["total_amount_negative"] = page::money(config::get_config_item("currency"), $total_amount_negative, "%s%m %c");
     $_FORM["running_balance"] = page::money(config::get_config_item("currency"), $running_balance, "%s%m %c");
     return array("totals" => $_FORM, "rows" => (array) $transactions);
 }
Beispiel #4
0
 function find_email($debug = false, $get_blobs = false, $ignore_date = false)
 {
     $info = inbox::get_mail_info();
     $mailbox = $this->get_value("commentMaster") . $this->get_value("commentMasterID");
     $mail = new email_receive($info);
     $mail->open_mailbox(config::get_config_item("allocEmailFolder") . "/" . $mailbox, OP_HALFOPEN + OP_READONLY);
     $mail->check_mail();
     $msg_nums = $mail->get_all_email_msg_uids();
     $debug and print "<hr><br><b>find_email(): " . date("Y-m-d H:i:s") . " found " . count($msg_nums) . " emails for mailbox: " . $mailbox . "</b>";
     // fetch and parse email
     foreach ((array) $msg_nums as $num) {
         $debug and print "<hr><br>Examining message number: " . $num;
         unset($mimebits);
         // this will stream output
         $mail->set_msg($num);
         $mail->get_msg_header();
         $text = $mail->fetch_mail_text();
         list($from1, $e1n) = parse_email_address($mail->mail_headers["from"]);
         list($from2, $e2n) = parse_email_address($this->get_value("commentCreatedUserText"));
         if (!$from2 && $this->get_value("commentCreatedUser")) {
             $p = new person();
             $p->set_id($this->get_value("commentCreatedUser"));
             $p->select();
             $from2 = $p->get_value("emailAddress");
         }
         if (!$from2 && $this->get_value("commentCreatedUserClientContactID")) {
             $p = new clientContact();
             $p->set_id($this->get_value("commentCreatedUserClientContactID"));
             $p->select();
             $from2 = $p->get_value("clientContactEmail");
         }
         $text1 = str_replace(array("\\s", "\n", "\r"), "", trim($text));
         $text2 = str_replace(array("\\s", "\n", "\r"), "", trim($this->get_value("comment")));
         $date = format_date("U", $this->get_value("commentCreatedTime"));
         $date1 = strtotime($mail->mail_headers["date"]) - 300;
         $date3 = strtotime($mail->mail_headers["date"]) + 300;
         similar_text($text1, $text2, $percent);
         if ($percent >= 99 && ($from1 == $from2 || !$from2 || same_email_address($from1, config::get_config_item("AllocFromEmailAddress"))) && ($date > $date1 && $date < $date3 || $ignore_date)) {
             $debug and print "<br><b style='color:green'>Found you! Msg no: " . $num . " in mailbox: " . $mailbox . " for commentID: " . $this->get_id() . "</b>";
             foreach ((array) $mail->mail_parts as $v) {
                 $s = $v["part_object"];
                 // structure
                 $raw_data = imap_fetchbody($mail->connection, $mail->msg_uid, $v["part_number"], FT_UID | FT_PEEK);
                 $thing = $mail->decode_part($s->encoding, $raw_data);
                 $filename = $mail->get_parameter_attribute_value($s->parameters, "name");
                 $filename or $filename = $mail->get_parameter_attribute_value($s->parameters, "filename");
                 $filename or $filename = $mail->get_parameter_attribute_value($s->dparameters, "name");
                 $filename or $filename = $mail->get_parameter_attribute_value($s->dparameters, "filename");
                 $bits = array();
                 $bits["part"] = $v["part_number"];
                 $bits["name"] = $filename;
                 $bits["size"] = strlen($thing);
                 $get_blobs and $bits["blob"] = $thing;
                 $filename and $mimebits[] = $bits;
             }
             $mail->close();
             return array($mail, $text, $mimebits);
         } else {
             similar_text($text1, $text2, $percent);
             $debug and print "<br>TEXT: " . sprintf("%d", $text1 == $text2) . " (" . sprintf("%d", $percent) . "%)";
             #$debug and print "<br>Text1:<br>".$text1."<br>* * *<br>";
             #$debug and print "Text2:<br>".$text2."<br>+ + +</br>";
             $debug and print "<br>FROM: " . sprintf("%d", $from1 == $from2 || !$from2 || same_email_address($from1, config::get_config_item("AllocFromEmailAddress")));
             $debug and print " From1: " . page::htmlentities($from1);
             $debug and print " From2: " . page::htmlentities($from2);
             $debug and print "<br>DATE: " . sprintf("%d", $date > $date1 && $date < $date3) . " (" . date("Y-m-d H:i:s", $date) . " | " . date("Y-m-d H:i:s", $date1) . " | " . date("Y-m-d H:i:s", $date3) . ")";
             $debug and print "<br>";
         }
     }
     $mail->close();
     return array(false, false, false);
 }
Beispiel #5
0
}
$TPL["paymentMethodOptions"] = $expenseForm->get_value("paymentMethod");
$TPL["reimbursementRequiredOption"] = $rr_label;
$scr_label = "No";
if ($expenseForm->get_value("seekClientReimbursement")) {
    $scr_sel = " checked";
    $scr_label = "Yes";
}
$TPL["seekClientReimbursementLabel"] = $scr_label;
$seekClientReimbursementOption = "<input type=\"checkbox\" value=\"1\" name=\"seekClientReimbursement\"" . $scr_sel . ">";
$scr_hidden = "<input type=\"hidden\" name=\"seekClientReimbursement\" value=\"" . $expenseForm->get_value("seekClientReimbursement") . "\">";
$TPL["seekClientReimbursementOption"] = $scr_label . $scr_hidden;
$c = new client();
$c->set_id($expenseForm->get_value("clientID"));
$c->select();
$clientName = page::htmlentities($c->get_name());
$clientName and $TPL["printer_clientID"] = $clientName;
$TPL["field_expenseFormComment"] = $expenseForm->get_value("expenseFormComment", DST_HTML_DISPLAY);
if (is_object($expenseForm) && $expenseForm->get_id() && check_optional_allow_edit()) {
    $TPL["expenseFormButtons"] .= '
  <button type="submit" name="cancel" value="1" class="delete_button">Delete<i class="icon-trash"></i></button>
  <button type="submit" name="save" value="1" class="save_button">Save<i class="icon-ok-sign"></i></button>
  <button type="submit" name="finalise" value="1" class="save_button">To Admin<i class="icon-arrow-right"></i></button>
  ';
    $TPL["paymentMethodOptions"] = "<select name=\"paymentMethod\">" . $paymentOptions . "</select>";
    $TPL["reimbursementRequiredOption"] = $reimbursementRequiredRadios;
    $TPL["seekClientReimbursementOption"] = $seekClientReimbursementOption;
    $options["clientStatus"] = "Current";
    $ops = client::get_list($options);
    $ops = array_kv($ops, "clientID", "clientName");
    $TPL["field_clientID"] = "<select name=\"clientID\"><option value=\"\">" . page::select_options($ops, $expenseForm->get_value("clientID")) . "</select>";
Beispiel #6
0
function get_attachments($entity, $id, $ops = array())
{
    global $TPL;
    $rows = array();
    $dir = ATTACHMENTS_DIR . $entity . DIRECTORY_SEPARATOR . $id;
    if (isset($id)) {
        #if (!is_dir($dir)) {
        #mkdir($dir, 0777);
        #}
        if (is_dir($dir)) {
            $handle = opendir($dir);
            // TODO add icons to files attachaments in general
            while (false !== ($file = readdir($handle))) {
                clearstatcache();
                if ($file != "." && $file != "..") {
                    $image = get_file_type_image($dir . DIRECTORY_SEPARATOR . $file);
                    $row["size"] = get_filesize_label($dir . DIRECTORY_SEPARATOR . $file);
                    $row["path"] = $dir . DIRECTORY_SEPARATOR . $file;
                    $row["file"] = "<a href=\"" . $TPL["url_alloc_getDoc"] . "id=" . $id . "&entity=" . $entity . "&file=" . urlencode($file) . "\">" . $image . $ops["sep"] . page::htmlentities($file) . "</a>";
                    $row["text"] = page::htmlentities($file);
                    #$row["delete"] = "<a href=\"".$TPL["url_alloc_delDoc"]."id=".$id."&entity=".$entity."&file=".urlencode($file)."\">Delete</a>";
                    $row["delete"] = "<form action=\"" . $TPL["url_alloc_delDoc"] . "\" method=\"post\">\n                            <input type=\"hidden\" name=\"id\" value=\"" . $id . "\">\n                            <input type=\"hidden\" name=\"file\" value=\"" . $file . "\">\n                            <input type=\"hidden\" name=\"entity\" value=\"" . $entity . "\">\n                            <input type=\"hidden\" name=\"sbs_link\" value=\"attachments\">\n                            <input type=\"hidden\" name=\"sessID\" value=\"{$sessID}\">" . '<button type="submit" name="delete_file_attachment" value="1" class="delete_button">Delete<i class="icon-trash"></i></button>' . "</form>";
                    $row["mtime"] = date("Y-m-d H:i:s", filemtime($dir . DIRECTORY_SEPARATOR . $file));
                    $row["restore_name"] = $file;
                    $rows[] = $row;
                }
            }
            closedir($handle);
        }
        is_array($rows) && usort($rows, "sort_by_mtime");
    }
    return $rows;
}
Beispiel #7
0
 function get_changes_list()
 {
     // This function returns HTML rows for the changes that have been made to this task
     $rows = array();
     $people_cache =& get_cached_table("person");
     $options = array("taskID" => $this->get_id());
     $changes = audit::get_list($options);
     foreach ($changes as $audit) {
         $changeDescription = "";
         $newValue = $audit['value'];
         switch ($audit['field']) {
             case 'created':
                 $changeDescription = $newValue;
                 break;
             case 'dip':
                 $changeDescription = "Default parties set to " . interestedParty::abbreviate($newValue);
                 break;
             case 'taskName':
                 $changeDescription = "Task name set to '{$newValue}'.";
                 break;
             case 'taskDescription':
                 $changeDescription = "Task description set to <a class=\"magic\" href=\"#x\" onclick=\"\$('#audit" . $audit["auditID"] . "').slideToggle('fast');\">Show</a> <div class=\"hidden\" id=\"audit" . $audit["auditID"] . "\"><div>" . $newValue . "</div></div>";
                 break;
             case 'priority':
                 $priorities = config::get_config_item("taskPriorities");
                 $changeDescription = sprintf('Task priority set to <span style="color: %s;">%s</span>.', $priorities[$newValue]["colour"], $priorities[$newValue]["label"]);
                 break;
             case 'projectID':
                 task::load_entity("project", $newValue, $newProject);
                 is_object($newProject) and $newProjectLink = $newProject->get_project_link();
                 $newProjectLink or $newProjectLink = "&lt;empty&gt;";
                 $changeDescription = "Project changed set to " . $newProjectLink . ".";
                 break;
             case 'parentTaskID':
                 task::load_entity("task", $newValue, $newTask);
                 if ($newValue) {
                     $changeDescription = sprintf("Task set to a child of %d %s.", $newTask->get_id(), $newTask->get_task_link());
                 } else {
                     $changeDescription = "Task no longer a child task.";
                 }
                 break;
             case 'duplicateTaskID':
                 task::load_entity("task", $newValue, $newTask);
                 if ($newValue) {
                     $changeDescription = "Task set to a duplicate of " . $newTask->get_task_link();
                 } else {
                     $changeDescription = "Task is no longer a duplicate.";
                 }
                 break;
             case 'personID':
                 $changeDescription = "Task assigned to " . $people_cache[$newValue]["name"] . ".";
                 break;
             case 'managerID':
                 $changeDescription = "Task manager set to " . $people_cache[$newValue]["name"] . ".";
                 break;
             case 'estimatorID':
                 $changeDescription = "Task estimator set to " . $people_cache[$newValue]["name"] . ".";
                 break;
             case 'taskTypeID':
                 $changeDescription = "Task type set to " . $newValue . ".";
                 break;
             case 'taskStatus':
                 $changeDescription = sprintf('Task status set to <span style="background-color:%s">%s</span>.', task::get_task_status_thing("colour", $newValue), task::get_task_status_thing("label", $newValue));
                 break;
             case 'dateActualCompletion':
             case 'dateActualStart':
             case 'dateTargetStart':
             case 'dateTargetCompletion':
             case 'timeLimit':
             case 'timeBest':
             case 'timeWorst':
             case 'timeExpected':
                 // these cases are more or less identical
                 switch ($audit['field']) {
                     case 'dateActualCompletion':
                         $fieldDesc = "actual completion date";
                         break;
                     case 'dateActualStart':
                         $fieldDesc = "actual start date";
                         break;
                     case 'dateTargetStart':
                         $fieldDesc = "estimate/target start date";
                         break;
                     case 'dateTargetCompletion':
                         $fieldDesc = "estimate/target completion date";
                         break;
                     case 'timeLimit':
                         $fieldDesc = "hours worked limit";
                         break;
                     case 'timeBest':
                         $fieldDesc = "best estimate";
                         break;
                     case 'timeWorst':
                         $fieldDesc = "worst estimate";
                         break;
                     case 'timeExpected':
                         $fieldDesc = "expected estimate";
                 }
                 if ($newValue) {
                     $changeDescription = "The {$fieldDesc} was set to {$newValue}.";
                 } else {
                     $changeDescription = "The {$fieldDesc} was removed.";
                 }
                 break;
         }
         $rows[] = "<tr><td class=\"nobr\">" . $audit["dateChanged"] . "</td><td>{$changeDescription}</td><td>" . page::htmlentities($people_cache[$audit["personID"]]["name"]) . "</td></tr>";
     }
     return implode("\n", $rows);
 }
Beispiel #8
0
 function get_value($dest = DST_VARIABLE, $parent = null)
 {
     if ($dest == DST_DATABASE) {
         if (isset($this->value) && imp($this->value) || $this->empty_to_null == false) {
             return "'" . db_esc($this->value) . "'";
         } else {
             return "NULL";
         }
     } else {
         if ($dest == DST_HTML_DISPLAY) {
             if ($this->type == "money" && imp($this->value)) {
                 $c = $parent->currency;
                 if ($this->currency && isset($parent->data_fields[$this->currency])) {
                     $c = $parent->get_value($this->currency);
                 }
                 if (!$c) {
                     alloc_error("db_field::get_value(): No currency specified for " . $parent->classname . "." . $this->name . " (currency:" . $c . ")");
                 } else {
                     if ($this->value == $parent->all_row_fields[$this->name]) {
                         return page::money($c, $this->value, "%mo");
                     }
                 }
             }
             return page::htmlentities($this->value);
         } else {
             return $this->value;
         }
     }
 }
Beispiel #9
0
 * 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";
$info["host"] = config::get_config_item("allocEmailHost");
$info["port"] = config::get_config_item("allocEmailPort");
$info["username"] = config::get_config_item("allocEmailUsername");
$info["password"] = config::get_config_item("allocEmailPassword");
$info["protocol"] = config::get_config_item("allocEmailProtocol");
if (!$info["host"]) {
    alloc_error("Email mailbox host not defined, assuming email function is inactive.", true);
}
$email_receive = new email_receive($info);
$email_receive->open_mailbox(config::get_config_item("allocEmailFolder"), OP_HALFOPEN | OP_READONLY);
$email_receive->set_msg($_REQUEST["id"]);
$new_nums = $email_receive->get_new_email_msg_uids();
in_array($_REQUEST["id"], (array) $new_nums) and $new = true;
$mail_text = $email_receive->fetch_mail_text();
$new and $email_receive->set_unread();
// might have to "unread" the email, if it was new, i.e. set it back to new
$email_receive->close();
echo nl2br(trim(page::htmlentities($mail_text)));
Beispiel #10
0
$dont_print_these_dirs = array(".", "..", "CVS", ".hg", ".bzr", "_darcs", ".git");
// relative path
$DIR = urldecode($_POST['dir']);
// full path
$PATH = realpath(wiki_module::get_wiki_path() . $DIR) . DIRECTORY_SEPARATOR;
if (path_under_path($PATH, wiki_module::get_wiki_path()) && is_dir($PATH)) {
    $files = scandir($PATH);
    natcasesort($files);
    $str .= "\n<ul class=\"jqueryFileTree\" style=\"display: none;\">";
    // All dirs
    foreach ($files as $file) {
        if (!in_array($file, $dont_print_these_dirs) && is_dir($PATH . $file)) {
            $str .= "\n  <li class=\"directory collapsed\"><a class=\"file\" href=\"#\" rel=\"" . page::htmlentities($DIR . $file . DIRECTORY_SEPARATOR) . "\">" . page::htmlentities($file) . "</a></li>";
        }
    }
    // All files
    foreach ($files as $file) {
        if (file_exists($PATH . $file) && $file != '.' && $file != '..' && !is_dir($PATH . $file) && is_readable($PATH . $file)) {
            unset($extra);
            !is_writable($PATH . $file) and $extra = "(ro) ";
            $ext = strtolower(preg_replace('/^.*\\./', '', $file));
            $str .= "\n  <li class=\"file ext_{$ext} nobr\">";
            $str .= "\n    <a style=\"position:relative;\" class=\"file nobr\" href=\"#x\" rel=\"" . page::htmlentities($DIR . $file) . "\">" . page::htmlentities($file);
            $str .= "<div class='faint nobr' style='top:0px; position:absolute;'>" . $extra . get_filesize_label($PATH . $file) . "</div></a>";
            $str .= "\n  </li>";
        }
    }
    $str .= "\n</ul>";
    #echo "<pre>".page::htmlentities($str)."</pre>";
    echo $str;
}
Beispiel #11
0
 function format_log($logs = array())
 {
     /*
       We're expecting each log entry to look like this:
       Hash: r2432432
       Author: Alex Lance
       Date: 43242432
       Msg: This is the commit message
     */
     $logs or $logs = array();
     $rtn or $rtn = array();
     foreach ($logs as $line) {
         if (preg_match("/^Hash: (\\w+)/", $line, $matches)) {
             $id = $matches[1];
         } else {
             if (preg_match("/^Author: (.*\$)/", $line, $matches)) {
                 $rtn[$id]["author"] = page::htmlentities(trim($matches[1]));
             } else {
                 if (preg_match("/^Date: (.*\$)/", $line, $matches)) {
                     $rtn[$id]["date"] = date("Y-m-d H:i:s", page::htmlentities(trim($matches[1])));
                 } else {
                     if (preg_match("/^Msg: (.+\$)/", $line, $matches)) {
                         $rtn[$id]["msg"] = page::htmlentities(trim($matches[1]));
                     }
                 }
             }
         }
     }
     return $rtn;
 }
Beispiel #12
0
 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();
 }
Beispiel #13
0
<?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/>.
*/
define("NO_REDIRECT", 1);
require_once "../alloc.php";
if ($_REQUEST["taskID"]) {
    $q = prepare("SELECT taskID, taskName FROM task WHERE taskID = %d", $_REQUEST["taskID"]);
    $db = new db_alloc();
    $row = $db->qr($q);
    echo page::htmlentities($row["taskID"] . " " . $row["taskName"]);
}
Beispiel #14
0
 public static function get_list($_FORM = array())
 {
     global $TPL;
     $current_user =& singleton("current_user");
     list($filter, $filter2) = person::get_list_filter($_FORM);
     $debug = $_FORM["debug"];
     $debug and print "<pre>_FORM: " . print_r($_FORM, 1) . "</pre>";
     $debug and print "<pre>filter: " . print_r($filter, 1) . "</pre>";
     $_FORM["return"] or $_FORM["return"] = "html";
     // Get averages for hours worked over the past fortnight and year
     if ($current_user->have_perm(PERM_PERSON_READ_MANAGEMENT) && $_FORM["showHours"]) {
         $t = new timeSheetItem();
         list($ts_hrs_col_1, $ts_dollars_col_1) = $t->get_averages(date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 14, date("Y"))));
         list($ts_hrs_col_2, $ts_dollars_col_2) = $t->get_fortnightly_average();
     } else {
         unset($_FORM["showHours"]);
     }
     // A header row
     $summary .= person::get_list_tr_header($_FORM);
     if (is_array($filter) && count($filter)) {
         $filter = " WHERE " . implode(" AND ", $filter);
     }
     if (is_array($filter2) && count($filter2)) {
         unset($filter["skill"]);
         $filter .= " AND " . implode(" OR ", $filter2);
     }
     $q = "SELECT person.*\n            FROM person\n       LEFT JOIN proficiency ON person.personID = proficiency.personID\n           " . $filter . "\n        GROUP BY username\n        ORDER BY firstName,surname,username";
     $debug and print "Query: " . $q;
     $db = new db_alloc();
     $db->query($q);
     while ($row = $db->next_record()) {
         $p = new person();
         if (!$p->read_db_record($db)) {
             continue;
         }
         $row = $p->perm_cleanup($row);
         // this is not the right way to do this - alla
         $print = true;
         $_FORM["showHours"] and $row["hoursSum"] = $ts_hrs_col_1[$row["personID"]];
         $_FORM["showHours"] and $row["hoursAvg"] = $ts_hrs_col_2[$row["personID"]];
         $row["name"] = $p->get_name();
         $row["name_link"] = $p->get_link($_FORM);
         $row["personActive_label"] = $p->get_value("personActive") == 1 ? "Y" : "";
         if ($_FORM["showSkills"]) {
             $senior_skills = $p->get_skills('Senior');
             $advanced_skills = $p->get_skills('Advanced');
             $intermediate_skills = $p->get_skills('Intermediate');
             $junior_skills = $p->get_skills('Junior');
             $novice_skills = $p->get_skills('Novice');
             $skills = array();
             $senior_skills and $skills[] = "<img src=\"../images/skill_senior.png\" alt=\"Senior=\"> " . page::htmlentities($senior_skills);
             $advanced_skills and $skills[] = "<img src=\"../images/skill_advanced.png\" alt=\"Advanced=\"> " . page::htmlentities($advanced_skills);
             $intermediate_skills and $skills[] = "<img src=\"../images/skill_intermediate.png\" alt=\"Intermediate=\"> " . page::htmlentities($intermediate_skills);
             $junior_skills and $skills[] = "<img src=\"../images/skill_junior.png\" alt=\"Junior=\"> " . page::htmlentities($junior_skills);
             $novice_skills and $skills[] = "<img src=\"../images/skill_novice.png\" alt=\"Novice\"> " . page::htmlentities($novice_skills);
             $row["skills_list"] = implode("<br>", $skills);
         }
         if ($_FORM["showLinks"]) {
             $row["navLinks"] = '<a href="' . $TPL["url_alloc_taskList"] . 'personID=' . $row["personID"] . '&taskView=byProject&applyFilter=1';
             $row["navLinks"] .= '&dontSave=1&taskStatus=open&projectType=Current">Tasks</a>&nbsp;&nbsp;';
             has("project") and $row["navLinks"] .= '<a href="' . $TPL["url_alloc_personGraph"] . 'personID=' . $row["personID"] . '">Graph</a>&nbsp;&nbsp;';
             $row["navLinks"] .= '<a href="' . $TPL["url_alloc_taskCalendar"] . 'personID=' . $row["personID"] . '">Calendar</a>&nbsp;&nbsp;';
             $dateFrom = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 28, date("Y")));
             $dateTo = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y")));
             $row["navLinks"] .= '<a href="' . $TPL["url_alloc_timeSheetGraph"] . 'personID=' . $row["personID"] . '&dateFrom=' . $dateFrom . '&dateTo=' . $dateTo . '&applyFilter=1&dontSave=1">Hours</a>';
         }
         $summary .= person::get_list_tr($row, $_FORM);
         $rows[$row["personID"]] = $row;
     }
     $rows or $rows = array();
     if ($print && $_FORM["return"] == "array") {
         return $rows;
     } else {
         if ($print && $_FORM["return"] == "html") {
             return "<table class=\"list sortable\">" . $summary . "</table>";
         } else {
             if (!$print && $_FORM["return"] == "html") {
                 return "<table style=\"width:100%\"><tr><td colspan=\"10\" style=\"text-align:center\"><b>No People Found</b></td></tr></table>";
             }
         }
     }
 }
Beispiel #15
0
$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 {
Beispiel #16
0
 public static function get_list($_FORM)
 {
     global $TPL;
     $filter = clientContact::get_list_filter($_FORM);
     if (is_array($filter) && count($filter)) {
         $filter = " WHERE " . implode(" AND ", $filter);
     }
     $q = "SELECT clientContact.*, client.*\n            FROM clientContact\n       LEFT JOIN client ON client.clientID = clientContact.clientID\n                 " . $filter . " \n        GROUP BY clientContact.clientContactID \n        ORDER BY clientContactName,clientContact.primaryContact asc";
     $db = new db_alloc();
     $db->query($q);
     while ($row = $db->next_record()) {
         $c = new client();
         $c->read_db_record($db);
         $row["clientLink"] = $c->get_client_link($_FORM);
         $row["clientContactEmail"] and $row["clientContactEmail"] = "<a href=\"mailto:" . page::htmlentities($row["clientContactName"] . " <" . $row["clientContactEmail"] . ">") . "\">" . page::htmlentities($row["clientContactEmail"]) . "</a>";
         $rows[] = $row;
     }
     return $rows;
 }
Beispiel #17
0
        <select name="changeTransactionStatus"><option value="">Transaction Status<option value="approved">Approve<option value="rejected">Reject</select>';
                $TPL["field_invoiceNum"] = $TPL["invoiceNum"];
                $TPL["field_invoiceName"] = page::htmlentities($TPL["invoiceName"]);
                $TPL["field_clientID"] = $client_link;
                $TPL["field_projectID"] = $project_link;
                $TPL["field_tfID"] = $tf_link;
                $TPL["field_maxAmount"] = page::money($currency, $TPL["maxAmount"], "%s%mo %c");
                $TPL["field_invoiceDateFrom"] = $TPL["invoiceDateFrom"];
                $TPL["field_invoiceDateTo"] = $TPL["invoiceDateTo"];
            } else {
                if ($invoice->get_value("invoiceStatus") == "finished") {
                    $TPL["invoice_buttons"] = '
        <button type="submit" name="save_and_MoveBack" value="1" class="save_button"><i class="icon-arrow-left" style="margin:0px; margin-right:5px"></i>Back</button>
    ';
                    $TPL["field_invoiceNum"] = $TPL["invoiceNum"];
                    $TPL["field_invoiceName"] = page::htmlentities($TPL["invoiceName"]);
                    $TPL["field_clientID"] = $client_link;
                    $TPL["field_projectID"] = $project_link;
                    $TPL["field_tfID"] = $tf_link;
                    $TPL["field_maxAmount"] = page::money($currency, $TPL["maxAmount"], "%s%mo %c");
                    $TPL["field_invoiceDateFrom"] = $TPL["invoiceDateFrom"];
                    $TPL["field_invoiceDateTo"] = $TPL["invoiceDateTo"];
                }
            }
        }
    }
} else {
    $TPL["field_invoiceNum"] = $TPL["invoiceNum"];
    $TPL["field_invoiceName"] = $TPL["invoiceName"];
    $TPL["field_clientID"] = $client_link;
    $TPL["field_projectID"] = $project_link;
Beispiel #18
0
 function get_changes_list()
 {
     // This function returns HTML rows for the changes that have been made to this project
     $rows = array();
     $people_cache =& get_cached_table("person");
     $timeUnit = new timeUnit();
     $timeUnits = array_reverse($timeUnit->get_assoc_array("timeUnitID", "timeUnitLabelA"), true);
     $options = array("projectID" => $this->get_id());
     $changes = audit::get_list($options);
     foreach ((array) $changes as $audit) {
         $changeDescription = "";
         $newValue = $audit['value'];
         switch ($audit['field']) {
             case 'created':
                 $changeDescription = $newValue;
                 break;
             case 'dip':
                 $changeDescription = "Default parties set to " . interestedParty::abbreviate($newValue);
                 break;
             case 'projectShortName':
                 $changeDescription = "Project nickname set to '{$newValue}'.";
                 break;
             case 'projectComments':
                 $changeDescription = "Project description set to <a class=\"magic\" href=\"#x\" onclick=\"\$('#audit" . $audit["auditID"] . "').slideToggle('fast');\">Show</a> <div class=\"hidden\" id=\"audit" . $audit["auditID"] . "\"><div>" . $newValue . "</div></div>";
                 break;
             case 'clientID':
                 $newClient = new client($newValue);
                 is_object($newClient) and $newClientLink = $newClient->get_link();
                 $newClientLink or $newClientLink = "&lt;empty&gt;";
                 $changeDescription = "Client set to " . $newClientLink . ".";
                 break;
             case 'clientContactID':
                 $newClientContact = new clientContact($newValue);
                 is_object($newClientContact) and $newClientContactLink = $newClientContact->get_link();
                 $newClientContactLink or $newClientContactLink = "&lt;empty&gt;";
                 $changeDescription = "Client contact set to " . $newClientContactLink . ".";
                 break;
             case 'projectType':
                 $changeDescription = "Project type set to " . $newValue . ".";
                 break;
             case 'projectBudget':
                 $changeDescription = "Project budget set to " . page::money($this->get_value("currencyTypeID"), $newValue) . ".";
                 break;
             case 'currencyTypeID':
                 $changeDescription = "Project currency set to " . $newValue . ".";
                 break;
             case 'projectStatus':
                 $changeDescription = "Project status set to " . $newValue . ".";
                 break;
             case 'projectName':
                 $changeDescription = "Project name set to '{$newValue}'.";
                 break;
             case 'cost_centre_tfID':
                 $newCostCentre = new tf($newValue);
                 is_object($newCostCentre) and $newCostCentreLink = $newCostCentre->get_link();
                 $newCostCentreLink or $newCostCentreLink = "&lt;empty&gt;";
                 $changeDescription = "Cost centre TF set to " . $newCostCentreLink . ".";
                 break;
             case 'customerBilledDollars':
                 $changeDescription = "Client billing set to " . page::money($this->get_value("currencyTypeID"), $newValue) . ".";
                 break;
             case 'defaultTaskLimit':
                 $changeDescription = "Default task limit set to " . $newValue . ".";
                 break;
             case 'defaultTimeSheetRate':
                 $changeDescription = "Default time sheet rate set to " . page::money($this->get_value("currencyTypeID"), $newValue) . ".";
                 break;
             case 'defaultTimeSheetRateUnitID':
                 $changeDescription = "Default time sheet rate unit set to '" . $timeUnits[$newValue] . "'.";
                 break;
             case 'projectPriority':
                 $priorities = config::get_config_item("projectPriorities");
                 $changeDescription = sprintf('Project priority set to <span style="color: %s;">%s</span>.', $priorities[$newValue]["colour"], $priorities[$newValue]["label"]);
                 break;
             case 'dateActualCompletion':
             case 'dateActualStart':
             case 'dateTargetStart':
             case 'dateTargetCompletion':
                 // these cases are more or less identical
                 switch ($audit['field']) {
                     case 'dateActualCompletion':
                         $fieldDesc = "actual completion date";
                         break;
                     case 'dateActualStart':
                         $fieldDesc = "actual start date";
                         break;
                     case 'dateTargetStart':
                         $fieldDesc = "estimate/target start date";
                         break;
                     case 'dateTargetCompletion':
                         $fieldDesc = "estimate/target completion date";
                         break;
                 }
                 if (!$newValue) {
                     $changeDescription = "The {$fieldDesc} was removed.";
                 } else {
                     $changeDescription = "The {$fieldDesc} set to {$newValue}.";
                 }
                 break;
         }
         $rows[] = "<tr><td class=\"nobr\">" . $audit["dateChanged"] . "</td><td>{$changeDescription}</td><td>" . page::htmlentities($people_cache[$audit["personID"]]["name"]) . "</td></tr>";
     }
     return implode("\n", $rows);
 }
Beispiel #19
0
 function get_timeSheetItem_list_items($timeSheetID)
 {
     global $TPL;
     list($db, $customerBilledDollars, $timeSheet, $unit_array, $currency) = $this->get_timeSheetItem_vars($timeSheetID);
     $m = new meta("timeSheetItemMultiplier");
     $multipliers = $m->get_list();
     while ($db->next_record()) {
         $timeSheetItem = new timeSheetItem();
         $timeSheetItem->read_db_record($db);
         $row_num++;
         $taskID = sprintf("%d", $timeSheetItem->get_value("taskID"));
         $num = sprintf("%0.2f", $timeSheetItem->get_value("timeSheetItemDuration"));
         $info["total"] += $num;
         $rows[$row_num]["date"] = $timeSheetItem->get_value("dateTimeSheetItem");
         $rows[$row_num]["units"] = $num . " " . $unit_array[$timeSheetItem->get_value("timeSheetItemDurationUnitID")];
         $rows[$row_num]["multiplier_string"] = $multipliers[$timeSheetItem->get_value("multiplier")]["timeSheetItemMultiplierName"];
         unset($str);
         $d = $timeSheetItem->get_value('taskID', DST_HTML_DISPLAY) . ": " . $timeSheetItem->get_value('description', DST_HTML_DISPLAY);
         $d && !$rows[$row_num]["desc"] and $str[] = "<b>" . $d . "</b>";
         // Get task description
         if ($taskID && $TPL["printDesc"]) {
             $t = new task();
             $t->set_id($taskID);
             $t->select();
             $d2 = str_replace("\r\n", "\n", $t->get_value("taskDescription", DST_HTML_DISPLAY));
             $d2 .= "\n";
             $d2 && !$d2s[$taskID] and $str[] = $d2;
             $d2 and $d2s[$taskID] = true;
         }
         $c = str_replace("\r\n", "\n", $timeSheetItem->get_value("comment"));
         !$timeSheetItem->get_value("commentPrivate") && $c and $str[] = page::htmlentities($c);
         is_array($str) and $rows[$row_num]["desc"] .= trim(implode(DEFAULT_SEP, $str));
     }
     $timeSheet->load_pay_info();
     $info["total"] = $timeSheet->pay_info["summary_unit_totals"];
     $rows or $rows = array();
     $info or $info = array();
     return array($rows, $info);
 }
Beispiel #20
0
}
// This needs to be just above the newTimeSheet_projectID logic
$projectID = $timeSheet->get_value("projectID");
// If we are entering the page from a project link: New time sheet
if ($_GET["newTimeSheet_projectID"] && !$projectID) {
    $_GET["taskID"] and $tid = "&taskID=" . $_GET["taskID"];
    $projectID = $_GET["newTimeSheet_projectID"];
    $db = new db_alloc();
    $q = prepare("SELECT * FROM timeSheet WHERE status = 'edit' AND personID = %d AND projectID = %d", $current_user->get_id(), $projectID);
    $db->query($q);
    if ($db->next_record()) {
        alloc_redirect($TPL["url_alloc_timeSheet"] . "timeSheetID=" . $db->f("timeSheetID") . $tid);
    }
}
if ($_GET["newTimeSheet_projectID"] && !$db->qr("SELECT * FROM projectPerson WHERE personID = %d AND projectID = %d", $current_user->get_id(), $_GET["newTimeSheet_projectID"])) {
    alloc_error("You are not a member of the project (id:" . page::htmlentities($_GET["newTimeSheet_projectID"]) . "), please get a manager to add you to the project.");
}
$db->query($query);
while ($db->row()) {
    $project_array[$db->f("projectID")] = $db->f("projectName");
}
$TPL["timeSheet_projectName"] = $project_array[$projectID];
$TPL["timeSheet_projectID"] = $projectID;
$TPL["taskID"] = $_GET["taskID"];
// Get the project record to determine which button for the edit status.
if ($projectID != 0) {
    $project = new project();
    $project->set_id($projectID);
    $project->select();
    $projectManagers = $project->get_timeSheetRecipients();
    if (!$projectManagers) {
Beispiel #21
0
function include_template($filename, $getString = false)
{
    global $TPL;
    $current_user =& singleton("current_user");
    $TPL["current_user"] = $current_user;
    $template = get_template($filename);
    #echo "<pre>".htmlspecialchars($template)."</pre>";
    // Make all variables available via $var
    is_array($TPL) && extract($TPL, EXTR_OVERWRITE);
    if ($getString) {
        // Begin buffering output to halt anything being sent to the web browser.
        ob_start();
    }
    $rtn = eval($template);
    if ($rtn === false && ($error = error_get_last())) {
        $s = DIRECTORY_SEPARATOR;
        $f = $filename;
        echo "<b style='color:red'>Error line " . $error['line'] . " in template: ";
        echo basename(dirname(dirname($f))) . $s . basename(dirname($f)) . $s . basename($f) . "</b>";
        $bits = explode("\n", $template);
        foreach ($bits as $k => $bit) {
            echo "<br>" . $k . "&nbsp;&nbsp;&nbsp;&nbsp;" . page::htmlentities($bit);
        }
        exit;
    }
    if ($getString) {
        // Grab everything that was captured in the output buffer and return
        // it as a string.
        return (string) ob_get_clean();
    }
}
Beispiel #22
0
<?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";
$prohibited[] = "alloc_config.php";
if ($_GET["dir"] && $_GET["file"]) {
    $path = realpath($_GET["dir"] . DIRECTORY_SEPARATOR . $_GET["file"]);
    $TPL["path"] = $path;
    if (path_under_path($path, ALLOC_MOD_DIR) && is_file($path) && !in_array(basename($path), $prohibited)) {
        $TPL["results"] = page::htmlentities(file_get_contents($path));
    }
}
include_template("templates/sourceCodeView.tpl");
Beispiel #23
0
                            // Wiki Search
                        } else {
                            if ($search && $needle && $category == "search_wiki") {
                                $TPL["search_title"] = "Wiki Search";
                                $index = new Zend_Search_Lucene(ATTACHMENTS_DIR . 'search/wiki');
                                $query = Zend_Search_Lucene_Search_QueryParser::parse($needle);
                                $hits = $index->find($needle);
                                $TPL["index_count"] = $index->count();
                                $TPL["hits_count"] = count($hits);
                                foreach ($hits as $hit) {
                                    $d = $hit->getDocument();
                                    $row = array();
                                    $row["idx"] = $hit->id;
                                    $row["score"] = sprintf('%d%%', $hit->score * 100);
                                    $row["title"] = sprintf("<a href='%starget=%s'>%s</a>", $TPL["url_alloc_wiki"], urlencode($d->getFieldValue('name')), page::htmlentities($d->getFieldValue('name')));
                                    $row["desc"] = page::htmlentities($d->getFieldValue('desc'));
                                    $TPL["search_results"][] = $row;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
// setup generic values
$TPL["search_category_options"] = page::get_category_options($category);
$TPL["needle"] = $needle;
$TPL["needle2"] = $needle;
if (!$needle || $noRedirect) {
Beispiel #24
0
$parent_task = $task->get_foreign_object("task", "parentTaskID");
$parent_task->set_values("parentTask_");
$TPL["taskType_taskTypeID"] = $task->get_value("taskTypeID");
$q = prepare("SELECT clientID FROM project LEFT JOIN task ON task.projectID = project.projectID WHERE taskID = %d", $task->get_id());
$db->query($q);
$db->next_record();
if ($db->f("clientID")) {
    $TPL["new_client_contact_link"] = "<br><br><a href=\"" . $TPL["url_alloc_client"] . "clientID=" . $db->f("clientID") . "\">";
    $TPL["new_client_contact_link"] .= "New Client Contact</a>";
    $TPL["task_clientID"] = $db->f("clientID");
}
$parentTaskIDs = get_parent_taskIDs($task->get_value("parentTaskID"));
if (is_array($parentTaskIDs)) {
    $parentTaskIDs = array_reverse($parentTaskIDs, 1);
    foreach ($parentTaskIDs as $tName => $tID) {
        $TPL["hierarchy_links"] .= $br . $spaces . "<a href=\"" . $TPL["url_alloc_task"] . "taskID=" . $tID . "\">" . $tID . " " . page::htmlentities($tName) . "</a>";
        $spaces .= "&nbsp;&nbsp;&nbsp;&nbsp;";
        $br = "<br>";
    }
}
// Link off to the source task, if this task is just a duplicate
$dupeID = $task->get_value("duplicateTaskID");
if ($dupeID) {
    $realtask = new task();
    $realtask->set_id($dupeID);
    $realtask->select();
    $TPL["taskDuplicateLink"] = $realtask->get_task_link(array("prefixTaskID" => 1, "return" => "html"));
    $mesg = "This task is a duplicate of " . $TPL["taskDuplicateLink"];
    $TPL["message_help_no_esc"][] = $mesg;
    $TPL["editing_disabled"] = true;
}
$messages[ACTION_CREATE_ALLOC_CONFIG] .= "<pre>&lt;?php <br>" . implode("\n", $newfile) . "\n?&gt;</pre>";
$messages[ACTION_CREATE_ALLOC_CONFIG] .= "Ensure that that less-than symbol &lt; on the first line is the very first character in the file, ";
$messages[ACTION_CREATE_ALLOC_CONFIG] .= "and that the greater-than symbol &gt; on the last line, is the absolute last character in the file.";
$messages[ACTION_MV_PROJECTS_DIR] = "Please rename " . ATTACHMENTS_DIR . "projects  to  " . ATTACHMENTS_DIR . "project";
$messages[ACTION_MV_CLIENTS_DIR] = "Please rename " . ATTACHMENTS_DIR . "clients  to  " . ATTACHMENTS_DIR . "client";
$messages[ACTION_MV_TASKS_DIR] = "Please create a webserver writeable directory: " . ATTACHMENTS_DIR . "task";
$messages[ACTION_ERR_ATTACHMENTS_DIR_NOT_DEFINED] = "ERROR: No ATTACHMENTS_DIR defined";
$messages[ACTION_ERR_ATTACHMENTS_DIR_NOT_DIR] = "ERROR: ATTACHMENTS_DIR is not a directory: " . ATTACHMENTS_DIR;
$messages[ACTION_ERR_ATTACHMENTS_DIR_NOT_WRITEABLE] = "ERROR: ATTACHMENTS_DIR is not webserver writeable: " . ATTACHMENTS_DIR;
$messages[ACTION_FIX_DB_USER_PERMS] = "The database user <b>" . ALLOC_DB_USER . "</b> does not have the correct permissions required to operate the new patch system.";
$messages[ACTION_CREATE_TABLE_PATCHLOG] = "The patchLog table needs to be created.";
// If we're hitting this script with wget as part of the automatic livealloc upgrade process
// we just want to return the commands, so that the util/patch.sh script will eval them
if ($_GET["return_commands"] && is_array($actions) && count($actions)) {
    foreach ($actions as $action) {
        echo $commands[$action] . "\n";
    }
    // Else hitting this script with a web browser, provide more verbose instructions
} else {
    if (is_array($actions) && count($actions)) {
        foreach ($actions as $action) {
            echo "<br><br> * " . $messages[$action];
            echo "<pre>Try the shell command:<br>" . page::htmlentities($commands[$action]) . "</pre>";
        }
        // Don't echo this for livealloc
    } else {
        if (!$_GET["return_commands"]) {
            echo "Please complete the upgrade by performing the <a href=\"patch.php\">database updates</a>.";
        }
    }
}
Beispiel #26
0
 function get_interested_parties_html($parties = array())
 {
     $current_user =& singleton("current_user");
     if (is_object($current_user) && $current_user->get_id()) {
         $current_user_email = $current_user->get_value("emailAddress");
     }
     foreach ((array) $parties as $email => $info) {
         $info["name"] or $info["name"] = $email;
         if ($info["name"]) {
             unset($sel, $c);
             $counter++;
             if ($current_user_email && same_email_address($current_user_email, $email)) {
                 $sel = " checked";
             }
             $info["selected"] and $sel = " checked";
             !$info["internal"] && $info["external"] and $c .= " warn";
             $str .= "<span width=\"150px\" class=\"nobr " . $c . "\" id=\"td_ect_" . $counter . "\" style=\"float:left; width:150px; margin-bottom:5px;\">";
             $str .= "<input id=\"ect_" . $counter . "\" type=\"checkbox\" name=\"commentEmailRecipients[]\" value=\"" . $info["identifier"] . "\"" . $sel . "> ";
             $str .= "<label for=\"ect_" . $counter . "\" title=\"" . $info["name"] . " &lt;" . $info["email"] . "&gt;\">" . page::htmlentities($info["name"]) . "</label></span>";
         }
     }
     return $str;
 }
Beispiel #27
0
 public static function get_list($_FORM)
 {
     /*
      * This is the definitive method of getting a list of clients that need a sophisticated level of filtering
      *
      */
     global $TPL;
     $filter = client::get_list_filter($_FORM);
     $debug = $_FORM["debug"];
     $debug and print "<pre>_FORM: " . print_r($_FORM, 1) . "</pre>";
     $debug and print "<pre>filter: " . print_r($filter, 1) . "</pre>";
     $_FORM["return"] or $_FORM["return"] = "html";
     if (is_array($filter) && count($filter)) {
         $filter = " WHERE " . implode(" AND ", $filter);
     }
     $cc = config::get_config_item("clientCategories");
     foreach ($cc as $k => $v) {
         $clientCategories[$v["value"]] = $v["label"];
     }
     $q = "SELECT client.*,clientContactName, clientContactEmail, clientContactPhone, clientContactMobile\n            FROM client \n       LEFT JOIN clientContact ON client.clientID = clientContact.clientID AND clientContact.clientContactActive = 1\n                 " . $filter . " \n        GROUP BY client.clientID \n        ORDER BY clientName,clientContact.primaryContact asc";
     $debug and print "Query: " . $q;
     $db = new db_alloc();
     $db2 = new db_alloc();
     $db->query($q);
     while ($row = $db->next_record()) {
         $print = true;
         $c = new client();
         $c->read_db_record($db);
         $row["clientCategoryLabel"] = $clientCategories[$c->get_value("clientCategory")];
         $row["clientLink"] = $c->get_client_link($_FORM);
         $row["clientContactEmail"] and $row["clientContactEmail"] = "<a href=\"mailto:" . page::htmlentities($row["clientContactName"] . " <" . $row["clientContactEmail"] . ">") . "\">" . page::htmlentities($row["clientContactEmail"]) . "</a>";
         $rows[$c->get_id()] = $row;
     }
     return (array) $rows;
 }
Beispiel #28
0
 }
 foreach ($_POST as $name => $value) {
     if (in_array($name, $fields_to_save)) {
         $id = config::get_config_item_id($name);
         $c = new config();
         $c->set_id($id);
         $c->select();
         if ($types[$name] == "text") {
             //current special case for the only money field
             if ($name == "defaultTimeSheetRate") {
                 $value = page::money(0, $_POST[$name], "%mi");
                 $c->set_value("value", $value);
             } else {
                 $c->set_value("value", $_POST[$name]);
             }
             $TPL[$name] = page::htmlentities($value);
         } else {
             if ($types[$name] == "array") {
                 $c->set_value("value", serialize($_POST[$name]));
                 $TPL[$name] = $_POST[$name];
             }
         }
         $c->save();
         $TPL["message_good"] = "Saved configuration.";
     }
 }
 // Handle the only checkbox specially. If more checkboxes are added this
 // should be rewritten.
 #echo var_dump($_POST);
 if ($_POST['sbs_link'] == "rss" && !$_POST['rssShowProject']) {
     $c = new config();
Beispiel #29
0
 public static function to_html($str = "", $maxlength = false)
 {
     $maxlength and $str = wordwrap($str, $maxlength, "\n");
     $str = page::htmlentities($str);
     $str = nl2br($str);
     return $str;
 }