예제 #1
0
 $adj_total = 0;
 $adj_lines = 0;
 $tot_amount = 0;
 while (true) {
     if (!isset($_POST['sku_' . $rowCnt]) || $_POST['sku_' . $rowCnt] == TEXT_SEARCH) {
         break;
     }
     $sku = db_prepare_input($_POST['sku_' . $rowCnt]);
     $qty = db_prepare_input($_POST['qty_' . $rowCnt]);
     $serialize_number = db_prepare_input($_POST['serial_' . $rowCnt]);
     $desc = db_prepare_input($_POST['desc_' . $rowCnt]);
     //	    $acct             = db_prepare_input($_POST['acct_'.$rowCnt]);
     $result = $db->Execute("select account_inventory_wage, account_cost_of_sales FROM " . TABLE_INVENTORY . " WHERE sku='{$sku}'");
     $_POST['acct_' . $rowCnt] = $result->fields['account_inventory_wage'];
     $_POST['cogs_acct_' . $rowCnt] = $result->fields['account_cost_of_sales'];
     $_POST['total_' . $rowCnt] = $glEntry->calculateCost($sku, $qty, $serialize_number);
     if ($sku && $sku != TEXT_SEARCH) {
         $glEntry->journal_rows[] = array('sku' => $sku, 'qty' => -$qty, 'gl_type' => 'adj', 'serialize_number' => $serialize_number, 'gl_account' => $result->fields['account_inventory_wage'], 'description' => $desc, 'credit_amount' => 0, 'debit_amount' => 0, 'post_date' => $post_date);
         $adj_lines++;
     }
     $tot_amount += $cost;
     $rowCnt++;
 }
 if ($adj_lines > 0) {
     $glEntry->journal_main_array['total_amount'] = $tot_amount;
     $glEntry->journal_rows[] = array('sku' => '', 'qty' => '', 'gl_type' => 'ttl', 'gl_account' => $result->fields['account_inventory_wage'], 'description' => BOX_INV_TRANSFER . ' - ' . $adj_reason, 'debit_amount' => 0, 'credit_amount' => 0, 'post_date' => $post_date);
     // *************** START TRANSACTION *************************
     $db->transStart();
     //	    $glEntry->override_cogs_acct = $adj_account; // force cogs account to be users specified account versus default inventory account
     if ($glEntry->Post($glEntry->id ? 'edit' : 'insert')) {
         $first_id = $glEntry->id;