Location: PHPKode > projects > NOLA > invmarkupadd.php
<? include('includes/main.php'); ?>
<? //invmarkupsetadd.php
     echo texttitle('Standard Markup Set Add');
     if ($id) { // have already saved main info, now need to save price level info
           for ($levelcounter=1;$levelcounter<=$counter;$levelcounter++) {
                 //first test to make sure not already in file
                 $recordSet=&$conn->Execute('select * from markupsetlevel where markupsetid='.sqlprep($id).' and pricelevelid='.sqlprep(${"levelid".$levelcounter}));
                if ($recordSet->EOF) {  // save now, no match found
                    if (${"price".$levelcounter}>0) {
                      checkpermissions('inv');
                      if ($conn->Execute("insert into markupsetlevel (pricelevelid,markupsetid,markuppercent) VALUES (".sqlprep(${"levelid".$levelcounter}).",".sqlprep($id).",".sqlprep(${"price".$levelcounter}).")") === false) {
                           echo texterror("Error adding Markup Set for Level.");
                      } else {
                           echo textsuccess("Markup Set for Level added successfully.");
                      };
                    };
                 };
           };
     } elseif ($description) { //if the user has submitted info
           $recordSet=&$conn->Execute('select * from markupset where description='.sqlprep($description));
           if (!$recordSet->EOF) die (texterror("Standard Markup Set already exists with that description"));
           checkpermissions('inv');
           if ($conn->Execute("insert into markupset (description, costbased) VALUES (".sqlprep($description).",".sqlprep($costbased).")") === false) die (texterror("Error adding Standard Markup Set."));
           $recordSet=&$conn->Execute('select id from markupset where description='.sqlprep($description));
           if (!$recordSet->EOF) $id=$recordSet->fields[0];
           // now ask for price level info for this set
           $recordSet=&$conn->Execute("select description, id from pricelevel");
           $counter=0;
           while (!$recordSet->EOF) {
                   $counter++;
                   ${"pricelevel".$counter} = $recordSet->fields[0];
                   ${"levelid".$counter}=$recordSet->fields[1];
                   $recordSet->MoveNext();
           };
           echo '<form action="invmarkupadd.php" method="post"><input type="hidden" name="nonprintable" value="1">';
           echo '<table><tr><th colspan="2">Markup Set Description: '.$description.'</th></tr>';
           echo '<tr><th>Price Level</th><th>Markup</th></tr>';
           echo '<input type="hidden" name="id" value="'.$id.'"><input type="hidden" name="description" value="'.$description.'"><input type="hidden" name="counter" value="'.$counter.'">';
           for ($levelcounter=1;$levelcounter<=$counter;$levelcounter++) {
                 echo '<td>'.${"pricelevel".$levelcounter}.'</td><td><input type="text" name="price'.$levelcounter.'" onchange="validatenum(this)" size="10" value="'.${"price".$levelcounter}.'" onKeyPress="return handleEnter(this, event)" onFocus="highlightField(this)" onBlur="normalField(this)"></td></tr>';
                 echo '<input type="hidden" name="levelid'.$levelcounter.'" value="'.${"levelid".$levelcounter}.'">';
           };
           echo '</table><input type="submit" value="Add"></form>';

     } else {
       echo '<form action="invmarkupadd.php" method="post"><input type="hidden" name="nonprintable" value="1">';
       echo '<table><tr><td align="'.TABLE_LEFT_SIDE_ALIGN.'">Markup Set Description:</td><td><input type="text" name="description" size="30"'.INC_TEXTBOX.'></td></td>';
       echo '<tr><td align="'.TABLE_LEFT_SIDE_ALIGN.'">Markup Based On:</td><td><select name="costbased"'.INC_TEXTBOX.'><option value="1">First Cost';
              echo '<option value="2">Mid Cost';
              echo '<option value="3">Last Cost';
       echo '</select></td></tr>';
       echo '</table><input type="submit" value="Add"></form>';
     };
?>
<? include('includes/footer.php'); ?>
Return current item: NOLA