当前位置: 首页>>代码示例>>PHP>>正文


PHP alloc_error函数代码示例

本文整理汇总了PHP中alloc_error函数的典型用法代码示例。如果您正苦于以下问题:PHP alloc_error函数的具体用法?PHP alloc_error怎么用?PHP alloc_error使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了alloc_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 function save()
 {
     $current_user =& singleton("current_user");
     global $TPL;
     $errors = $this->validate();
     if ($errors) {
         alloc_error($errors);
     } else {
         $existing = $this->all_row_fields;
         if ($existing["taskStatus"] != $this->get_value("taskStatus")) {
             $db = new db_alloc();
             $db->query("call change_task_status(%d,'%s')", $this->get_id(), $this->get_value("taskStatus"));
             $row = $db->qr("SELECT taskStatus\n                              ,dateActualCompletion\n                              ,dateActualStart\n                              ,dateClosed\n                              ,closerID\n                          FROM task\n                         WHERE taskID = %d", $this->get_id());
             // Changing a task's status changes these fields.
             // Unfortunately the call to save() below erroneously nukes these fields.
             // So we manually set them to whatever change_task_status() has dictated.
             $this->set_value("taskStatus", $row["taskStatus"]);
             $this->set_value("dateActualCompletion", $row["dateActualCompletion"]);
             $this->set_value("dateActualStart", $row["dateActualStart"]);
             $this->set_value("dateClosed", $row["dateClosed"]);
             $this->set_value("closerID", $row["closerID"]);
         }
         return parent::save();
     }
 }
开发者ID:cjbayliss,项目名称:alloc,代码行数:25,代码来源:task.inc.php

示例2: save

 function save()
 {
     $current_user =& singleton("current_user");
     $timeSheet = new timeSheet();
     $timeSheet->set_id($this->get_value("timeSheetID"));
     $timeSheet->select();
     $timeSheet->load_pay_info();
     list($amount_used, $amount_allocated) = $timeSheet->get_amount_allocated("%mo");
     $this->currency = $timeSheet->get_value("currencyTypeID");
     $this->set_value("comment", rtrim($this->get_value("comment")));
     $amount_of_item = $this->calculate_item_charge($timeSheet->get_value("currencyTypeID"), $timeSheet->get_value("customerBilledDollars"));
     if ($amount_allocated && $amount_of_item + $amount_used > $amount_allocated) {
         alloc_error("Adding this Time Sheet Item would exceed the amount allocated on the Pre-paid invoice. Time Sheet Item not saved.");
     }
     // If unit is changed via CLI
     if ($this->get_value("timeSheetItemDurationUnitID") && $timeSheet->pay_info["project_rateUnitID"] && $timeSheet->pay_info["project_rateUnitID"] != $this->get_value("timeSheetItemDurationUnitID") && !$timeSheet->can_edit_rate()) {
         alloc_error("Not permitted to edit time sheet item unit.");
     }
     if (!$this->get_value("timeSheetItemDurationUnitID") && $timeSheet->pay_info["project_rateUnitID"]) {
         $this->set_value("timeSheetItemDurationUnitID", $timeSheet->pay_info["project_rateUnitID"]);
     }
     // Last ditch perm checking - useful for the CLI
     if (!is_object($timeSheet) || !$timeSheet->get_id()) {
         alloc_error("Unknown time sheet.");
     }
     if ($timeSheet->get_value("status") != "edit" && !$this->skip_tsi_status_check) {
         alloc_error("Time sheet is not at status edit");
     }
     if (!$this->is_owner()) {
         alloc_error("Time sheet is not editable for you.");
     }
     $rtn = parent::save();
     $timeSheet->update_related_invoices();
     return $rtn;
 }
开发者ID:cjbayliss,项目名称:alloc,代码行数:35,代码来源:timeSheetItem.inc.php

示例3: get_balance

 function get_balance($where = array(), $debug = "")
 {
     $current_user =& singleton("current_user");
     // If no status is requested then default to approved.
     $where["status"] or $where["status"] = "approved";
     if (!$this->is_owner() && !$current_user->have_role("admin")) {
         return false;
     }
     // Get belance
     $db = new db_alloc();
     $query = prepare("SELECT sum( if(fromTfID=%d,-amount,amount) * pow(10,-currencyType.numberToBasic) * exchangeRate) AS balance \n                        FROM transaction \n                   LEFT JOIN currencyType ON transaction.currencyTypeID = currencyType.currencyTypeID\n                       WHERE (tfID = %d or fromTfID = %d) ", $this->get_id(), $this->get_id(), $this->get_id());
     // Build up the rest of the WHERE sql
     foreach ($where as $column_name => $value) {
         $op = " = ";
         if (is_array($value)) {
             $op = $value[0];
             $value = $value[1];
         }
         $query .= " AND " . $column_name . $op . " '" . db_esc($value) . "'";
     }
     #echo "<br>".$debug." q: ".$query;
     $db->query($query);
     $db->next_record() || alloc_error("TF {$tfID} not found in tf::get_balance");
     return $db->f("balance");
 }
开发者ID:cjbayliss,项目名称:alloc,代码行数:25,代码来源:tf.inc.php

示例4: get_value

 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;
         }
     }
 }
开发者ID:cjbayliss,项目名称:alloc,代码行数:29,代码来源:db_field.inc.php

示例5: apply_patch

function apply_patch($f)
{
    global $TPL;
    static $files;
    // Should never attempt to apply the same patch twice.. in case
    // there are function declarations in the .php patches.
    if ($files[$f]) {
        return;
    }
    $files[$f] = true;
    $db = new db_alloc();
    $file = basename($f);
    $failed = false;
    $comments = array();
    // This is an important patch that converts money from 120.34 to 12034.
    // We MUST ensure that the user has a currency set before applying this patch.
    if ($file == "patch-00188-alla.sql") {
        if (!config::get_config_item('currency')) {
            alloc_error("No default currency is set! Login to alloc (ignore any errors, you may need to manually change the url to config/config.php after logging in) go to Setup -> Finance and select a Main Currency. And then click the 'Update Transactions That Have No Currency' button. Then return here and apply this patch (patch-188). IT IS REALLY IMPORTANT THAT YOU FOLLOW THESE INSTRUCTIONS as the storage format for monetary amounts has changed.", true);
        }
    }
    // Try for sql file
    if (strtolower(substr($file, -4)) == ".sql") {
        list($sql, $comments) = parse_sql_file($f);
        foreach ($sql as $query) {
            if (!$db->query($query)) {
                #$TPL["message"][] = "<b style=\"color:red\">Error:</b> ".$f."<br>".$db->get_error();
                $failed = true;
                alloc_error("<b style=\"color:red\">Error:</b> " . $f . "<br>" . $db->get_error());
            }
        }
        if (!$failed) {
            $TPL["message_good"][] = "Successfully Applied: " . $f;
        }
        // Try for php file
    } else {
        if (strtolower(substr($file, -4)) == ".php") {
            $str = execute_php_file("../patches/" . $file);
            if ($str && !defined("FORCE_PATCH_SUCCEED_" . $file)) {
                #$TPL["message"][] = "<b style=\"color:red\">Error:</b> ".$f."<br>".$str;
                $failed = true;
                ob_end_clean();
                alloc_error("<b style=\"color:red\">Error:</b> " . $f . "<br>" . $str);
            } else {
                $TPL["message_good"][] = "Successfully Applied: " . $f;
            }
        }
    }
    if (!$failed) {
        $q = prepare("INSERT INTO patchLog (patchName, patchDesc, patchDate) \n                  VALUES ('%s','%s','%s')", $file, implode(" ", $comments), date("Y-m-d H:i:s"));
        $db->query($q);
    }
}
开发者ID:cjbayliss,项目名称:alloc,代码行数:53,代码来源:patch.php

示例6: save

 function save()
 {
     // Just ensure multiple 0 entries cannot be saved.
     if ($this->get_value("commissionPercent") == 0) {
         $q = prepare("SELECT * FROM projectCommissionPerson WHERE projectID = %d AND commissionPercent = 0 AND projectCommissionPersonID != %d", $this->get_value("projectID"), $this->get_id());
         $db = new db_alloc();
         $db->query($q);
         if ($db->next_record()) {
             $fail = true;
             alloc_error("Only one Time Sheet Commission is allowed to be set to 0%");
         }
     }
     if (!$fail) {
         parent::save();
     }
 }
开发者ID:cjbayliss,项目名称:alloc,代码行数:16,代码来源:projectCommissionPerson.inc.php

示例7: add_tsiHint

 function add_tsiHint($stuff)
 {
     $current_user =& singleton("current_user");
     $errstr = "Failed to record new time sheet item hint. ";
     $username = $stuff["username"];
     $people = person::get_people_by_username();
     $personID = $people[$username]["personID"];
     $personID or alloc_error("Person " . $username . " not found.");
     $taskID = $stuff["taskID"];
     $projectID = $stuff["projectID"];
     $duration = $stuff["duration"];
     $comment = $stuff["comment"];
     $date = $stuff["date"];
     if ($taskID) {
         $task = new task();
         $task->set_id($taskID);
         $task->select();
         $projectID = $task->get_value("projectID");
         $extra = " for task " . $taskID;
     }
     $projectID or alloc_error(sprintf($errstr . "No project found%s.", $extra));
     $row_projectPerson = projectPerson::get_projectPerson_row($projectID, $current_user->get_id());
     $row_projectPerson or alloc_error($errstr . "The person(" . $current_user->get_id() . ") has not been added to the project(" . $projectID . ").");
     if ($row_projectPerson && $projectID) {
         // Add new time sheet item
         $tsiHint = new tsiHint();
         $d = $date or $d = date("Y-m-d");
         $tsiHint->set_value("date", $d);
         $tsiHint->set_value("duration", $duration);
         if (is_object($task)) {
             $tsiHint->set_value("taskID", sprintf("%d", $taskID));
         }
         $tsiHint->set_value("personID", $personID);
         $tsiHint->set_value("comment", $comment);
         $tsiHint->save();
         $ID = $tsiHint->get_id();
     }
     if ($ID) {
         return array("status" => "yay", "message" => $ID);
     } else {
         alloc_error($errstr . "Time hint not added.");
     }
 }
开发者ID:cjbayliss,项目名称:alloc,代码行数:43,代码来源:tsiHint.inc.php

示例8: save

 function save()
 {
     // These need to be in here instead of validate(), because
     // validate is called after save() and we need these values set for save().
     $this->get_value("currencyTypeID") or $this->set_value("currencyTypeID", config::get_config_item("currency"));
     $this->get_value("destCurrencyTypeID") or $this->set_value("destCurrencyTypeID", config::get_config_item("currency"));
     // The data prior to the save
     $old = $this->all_row_fields;
     if ($old["status"] != $this->get_value("status") && $this->get_value("status") == "approved") {
         $this->set_value("dateApproved", date("Y-m-d"));
         $field_changed = true;
     } else {
         if ($this->get_value("status") != "approved") {
             $this->set_value("dateApproved", "");
         }
     }
     if ($old["currencyTypeID"] != $this->get_value("currencyTypeID")) {
         $field_changed = true;
     }
     if ($old["destCurrencyTypeID"] != $this->get_value("destCurrencyTypeID")) {
         $field_changed = true;
     }
     $db = new db_alloc();
     // If there already is an exchange rate set for an approved
     // transaction, then there's no need to update the exchange rate
     if ($this->get_value("exchangeRate") && $this->get_value("dateApproved") && !$field_changed) {
         // Else update the transaction's exchange rate
     } else {
         $this->get_value("transactionCreatedTime") and $date = format_date("Y-m-d", $this->get_value("transactionCreatedTime"));
         $this->get_value("transactionModifiedTime") and $date = format_date("Y-m-d", $this->get_value("transactionModifiedTime"));
         $this->get_value("transactionDate") and $date = $this->get_value("transactionDate");
         $this->get_value("dateApproved") and $date = $this->get_value("dateApproved");
         $er = exchangeRate::get_er($this->get_value("currencyTypeID"), $this->get_value("destCurrencyTypeID"), $date);
         if (!$er) {
             alloc_error("Unable to determine exchange rate for " . $this->get_value("currencyTypeID") . " to " . $this->get_value("destCurrencyTypeID") . " for date: " . $date);
         } else {
             $this->set_value("exchangeRate", $er);
         }
     }
     return parent::save();
 }
开发者ID:cjbayliss,项目名称:alloc,代码行数:41,代码来源:transaction.inc.php

示例9: PclZip

 function PclZip($p_zipname)
 {
     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::PclZip', "zipname=$p_zipname");
     // ----- Tests the zlib
     if (!function_exists('gzopen')) {
         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 1, "zlib extension seems to be missing");
         alloc_error('Abort ' . basename(__FILE__) . ' : Missing zlib extensions');
     }
     // ----- Set the attributes
     $this->zipname = $p_zipname;
     $this->zip_fd = 0;
     $this->magic_quotes_status = -1;
     // ----- Return
     //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 1);
     return;
 }
开发者ID:cjbayliss,项目名称:alloc,代码行数:16,代码来源:PclZip.inc.php

示例10: alloc_error

 * 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";
if (!config::get_config_item("mainTfID")) {
    alloc_error("This functionality will not work until you set a Finance TF on the Setup -> Finance screen.");
}
$field_map = array("date" => 0, "account" => 1, "num" => 2, "description" => 3, "memo" => 4, "category" => 5, "clr" => 6, "amount" => 7);
if ($_POST["upload"]) {
    $db = new db_alloc();
    is_uploaded_file($_FILES["expenses_file"]["tmp_name"]) || alloc_error("File referred to was not an uploaded file", true);
    // Prevent attacks by setting $expenses_file in URL
    $lines = file($_FILES["expenses_file"]["tmp_name"]);
    reset($lines);
    while (list(, $line) = each($lines)) {
        // Ignore blank lines
        if (trim($line) == "") {
            continue;
        }
        // Read field values from the line
        $fields = explode("\t", $line);
        $date = trim($fields[$field_map["date"]]);
        $account = trim($fields[$field_map["account"]]);
        $num = trim($fields[$field_map["num"]]);
        $description = trim($fields[$field_map["description"]]);
        $memo = trim($fields[$field_map["memo"]]);
开发者ID:cjbayliss,项目名称:alloc,代码行数:31,代码来源:expenseUpload.php

示例11: add_comment_from_email

 function add_comment_from_email($email_receive, $entity)
 {
     $current_user =& singleton("current_user");
     $commentID = comment::add_comment($entity->classname, $entity->get_id(), $email_receive->get_converted_encoding());
     $commentID or alloc_error("Unable to create an alloc comment (" . $entity->classname . ":" . $entity->get_id() . ") from email.");
     $comment = new comment();
     $comment->set_id($commentID);
     $comment->select();
     $comment->set_value("commentEmailUID", $email_receive->msg_uid);
     $comment->set_value("commentEmailMessageID", $email_receive->mail_headers["message-id"]);
     $comment->rename_email_attachment_dir($email_receive->dir);
     // Try figure out and populate the commentCreatedUser/commentCreatedUserClientContactID fields
     list($from_address, $from_name) = parse_email_address($email_receive->mail_headers["from"]);
     list($personID, $clientContactID, $from_name) = comment::get_person_and_client($from_address, $from_name, $entity->get_project_id());
     $personID and $comment->set_value('commentCreatedUser', $personID);
     $clientContactID and $comment->set_value('commentCreatedUserClientContactID', $clientContactID);
     $comment->set_value("commentCreatedUserText", $email_receive->mail_headers["from"]);
     $comment->set_value("commentEmailMessageID", $email_receive->mail_headers["message-id"]);
     $comment->updateSearchIndexLater = true;
     $comment->skip_modified_fields = true;
     $comment->save();
     if ($email_receive->mimebits) {
         comment::update_mime_parts($comment->get_id(), $email_receive->mimebits);
     }
     // CYBER-ONLY: Re-open task, if comment has been made by an external party.
     if (config::for_cyber() && !$comment->get_value('commentCreatedUser')) {
         $e = $entity->get_parent_object();
         if ($e->classname == "task" && substr($e->get_value("taskStatus"), 0, 4) != "open") {
             $tmp = $current_user;
             $current_user = new person();
             $personID = $e->get_value("managerID") or $personID = $e->get_value("personID") or $personID = $e->get_value("creatorID");
             $current_user->load_current_user($personID);
             // fake identity
             singleton("current_user", $current_user);
             $e->set_value("taskStatus", "open_inprogress");
             $e->save();
             $current_user = $tmp;
         }
     }
     return $comment;
 }
开发者ID:cjbayliss,项目名称:alloc,代码行数:41,代码来源:comment.inc.php

示例12: rtrim

 if ($_POST["save"]) {
     $expenseForm->read_globals();
     if ($expenseForm->get_value("reimbursementRequired") == 0 || $expenseForm->get_value("reimbursementRequired") == 1) {
         $expenseForm->set_value("paymentMethod", "");
     }
     $expenseForm->set_value("seekClientReimbursement", $_POST["seekClientReimbursement"] ? 1 : 0);
     $expenseForm->set_value("expenseFormComment", rtrim($expenseForm->get_value("expenseFormComment")));
     $expenseForm->save();
     alloc_redirect($TPL["url_alloc_expenseForm"] . "expenseFormID=" . $expenseForm->get_id());
     exit;
 } else {
     if ($_POST["finalise"]) {
         $db = new db_alloc();
         $hasItems = $db->qr("SELECT * FROM transaction WHERE expenseFormID = %d", $expenseForm->get_id());
         if (!$hasItems) {
             alloc_error("Unable to submit expense form, no items have been added.");
             alloc_redirect($TPL["url_alloc_expenseForm"] . "expenseFormID=" . $expenseForm->get_id());
             exit;
         }
         $expenseForm->read_globals();
         if ($expenseForm->get_value("reimbursementRequired") == 0 || $expenseForm->get_value("reimbursementRequired") == 1) {
             $expenseForm->set_value("paymentMethod", "");
         }
         $expenseForm->set_value("seekClientReimbursement", $_POST["seekClientReimbursement"] ? 1 : 0);
         $expenseForm->set_value("expenseFormFinalised", 1);
         $expenseForm->set_value("expenseFormComment", rtrim($expenseForm->get_value("expenseFormComment")));
         $expenseForm->save();
         alloc_redirect($TPL["url_alloc_expenseForm"] . "expenseFormID=" . $expenseForm->get_id());
         exit;
     } else {
         if ($_POST["unfinalise"]) {
开发者ID:cjbayliss,项目名称:alloc,代码行数:31,代码来源:expenseForm.php

示例13: add_remove_ips

 function add_remove_ips($ip, $entity, $entityID, $projectID = null)
 {
     $parties = explode(",", $ip);
     foreach ($parties as $party) {
         $party = trim($party);
         // remove an ip
         if ($party[0] == "%") {
             list($personID, $name, $email) = interestedParty::expand_ip(implode("", array_slice(str_split($party), 1)), $projectID);
             interestedParty::delete_interested_party($entity, $entityID, $email);
             // add an ip
         } else {
             list($personID, $name, $email) = interestedParty::expand_ip($party, $projectID);
             if (!$email || strpos($email, "@") === false) {
                 alloc_error("Unable to add interested party: " . $party);
             } else {
                 interestedParty::add_interested_party(array("entity" => $entity, "entityID" => $entityID, "fullName" => $name, "emailAddress" => $email, "personID" => $personID));
             }
         }
     }
 }
开发者ID:cjbayliss,项目名称:alloc,代码行数:20,代码来源:interestedParty.inc.php

示例14: get_value

 function get_value($field_name, $dest = DST_VARIABLE)
 {
     $field = $this->data_fields[$field_name];
     if (!is_object($field)) {
         $msg = "Field {$field_name} does not exist in " . $this->data_table;
         alloc_error($msg);
         return $msg;
     }
     if (!$this->can_read_field($field_name)) {
         return "Permission denied to " . $this->permissions[$this->data_fields[$field_name]->read_perm_name] . " of " . $this->data_table . "." . $field_name;
     }
     $c = $this->currency;
     if (isset($this->data_fields["currencyTypeID"]) && imp($this->data_fields["currencyTypeID"]->get_value())) {
         $c = $this->data_fields["currencyTypeID"]->get_value();
     }
     $c and $this->currency = $c;
     return $field->get_value($dest, $this);
 }
开发者ID:cjbayliss,项目名称:alloc,代码行数:18,代码来源:db_entity.inc.php

示例15: add_timeSheetItem

 function add_timeSheetItem($stuff)
 {
     $current_user =& singleton("current_user");
     $errstr = "Failed to record new time sheet item. ";
     $taskID = $stuff["taskID"];
     $projectID = $stuff["projectID"];
     $duration = $stuff["duration"];
     $comment = $stuff["comment"];
     $emailUID = $stuff["msg_uid"];
     $emailMessageID = $stuff["msg_id"];
     $date = $stuff["date"];
     $unit = $stuff["unit"];
     $multiplier = $stuff["multiplier"];
     if ($taskID) {
         $task = new task();
         $task->set_id($taskID);
         $task->select();
         $projectID = $task->get_value("projectID");
         $extra = " for task " . $taskID;
     }
     $projectID or alloc_error(sprintf($errstr . "No project found%s.", $extra));
     $row_projectPerson = projectPerson::get_projectPerson_row($projectID, $current_user->get_id());
     $row_projectPerson or alloc_error($errstr . "The person(" . $current_user->get_id() . ") has not been added to the project(" . $projectID . ").");
     if ($row_projectPerson && $projectID) {
         if ($stuff["timeSheetID"]) {
             $q = prepare("SELECT *\n                        FROM timeSheet\n                       WHERE status = 'edit'\n                         AND personID = %d\n                         AND timeSheetID = %d\n                    ORDER BY dateFrom\n                       LIMIT 1\n                  ", $current_user->get_id(), $stuff["timeSheetID"]);
             $db = new db_alloc();
             $db->query($q);
             $row = $db->row();
             $row or alloc_error("Couldn't find an editable time sheet with that ID.");
         } else {
             $q = prepare("SELECT *\n                        FROM timeSheet\n                       WHERE status = 'edit'\n                         AND projectID = %d\n                         AND personID = %d\n                    ORDER BY dateFrom\n                       LIMIT 1\n                  ", $projectID, $current_user->get_id());
             $db = new db_alloc();
             $db->query($q);
             $row = $db->row();
         }
         // If no timeSheets add a new one
         if (!$row) {
             $project = new project();
             $project->set_id($projectID);
             $project->select();
             $timeSheet = new timeSheet();
             $timeSheet->set_value("projectID", $projectID);
             $timeSheet->set_value("status", "edit");
             $timeSheet->set_value("personID", $current_user->get_id());
             $timeSheet->set_value("recipient_tfID", $current_user->get_value("preferred_tfID"));
             $timeSheet->set_value("customerBilledDollars", page::money($project->get_value("currencyTypeID"), $project->get_value("customerBilledDollars"), "%mo"));
             $timeSheet->set_value("currencyTypeID", $project->get_value("currencyTypeID"));
             $timeSheet->save();
             $timeSheetID = $timeSheet->get_id();
             // Else use the first timesheet we found
         } else {
             $timeSheetID = $row["timeSheetID"];
         }
         $timeSheetID or alloc_error($errstr . "Couldn't locate an existing, or create a new Time Sheet.");
         // Add new time sheet item
         if ($timeSheetID) {
             $timeSheet = new timeSheet();
             $timeSheet->set_id($timeSheetID);
             $timeSheet->select();
             $tsi = new timeSheetItem();
             $tsi->currency = $timeSheet->get_value("currencyTypeID");
             $tsi->set_value("timeSheetID", $timeSheetID);
             $d = $date or $d = date("Y-m-d");
             $tsi->set_value("dateTimeSheetItem", $d);
             $tsi->set_value("timeSheetItemDuration", $duration);
             $tsi->set_value("timeSheetItemDurationUnitID", $unit);
             if (is_object($task)) {
                 $tsi->set_value("description", $task->get_name());
                 $tsi->set_value("taskID", sprintf("%d", $taskID));
                 $_POST["timeSheetItem_taskID"] = sprintf("%d", $taskID);
                 // this gets used in timeSheetItem->save();
             }
             $tsi->set_value("personID", $current_user->get_id());
             $tsi->set_value("rate", page::money($timeSheet->get_value("currencyTypeID"), $row_projectPerson["rate"], "%mo"));
             $tsi->set_value("multiplier", $multiplier);
             $tsi->set_value("comment", $comment);
             $tsi->set_value("emailUID", $emailUID);
             $tsi->set_value("emailMessageID", $emailMessageID);
             $tsi->save();
             $id = $tsi->get_id();
             $tsi = new timeSheetItem();
             $tsi->set_id($id);
             $tsi->select();
             $ID = $tsi->get_value("timeSheetID");
         }
     }
     if ($ID) {
         return array("status" => "yay", "message" => $ID);
     } else {
         alloc_error($errstr . "Time not added.");
     }
 }
开发者ID:cjbayliss,项目名称:alloc,代码行数:93,代码来源:timeSheet.inc.php


注:本文中的alloc_error函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。