Supplier is the person or organization that provide materials for constructions. Acme Constructions purchases raw materials form these suppliers. When adding a supplier following data are recorded in the "suppliers" table.
Managing supplier details in the application are handled in the Suppliers menu. To create a new supplier go to "Suppliers --> New Supplier" menu and enter supplier details. To eliminate supplicated records, we check supplier name against names saved in the database.
Following the source code for new_supplier.php
<?php include("inc/page_header.php"); ?> <?php if(check('Add/Edit Customers') != 'Valid'){ header("Location: sys_home.php?pre=error"); ob_end_flush(); } ?> <div class="wrapper"> <div class="s60"> <div class="boxtitle">Supplier Details</div> <?php // form handling on submit if(isset($_POST['submit'])){ $supplier_name = $_POST['supplier_name']; $add1 = $_POST['add1']; $add2 = $_POST['add2']; $city = $_POST['city']; $telephone = $_POST['telephone']; $fax = $_POST['fax']; $email = $_POST['email']; $web = $_POST['web']; $comm = $_POST['comm']; $title = $_POST['custitle']; if($supplier_name == ''){ $error = "Please enter Supplier Name!"; } if($telephone == ''){ $error = "Please enter Telephone!"; } if($city == ''){ $error = "Please enter City / Country!"; } // duplicates $q = mysql_query("SELECT * FROM suppliers WHERE Supplier_Name = '$supplier_name'"); if(mysql_num_rows($q) > 0){ $error = "This supplier is already in the system!"; } if(!isset($error)){ mysql_query(" INSERT INTO suppliers (Supplier_Title, Supplier_Name, Supplier_Address, Supplier_Address_2, Supplier_City, Supplier_Telephone, Supplier_Fax, Supplier_Email, Supplier_Web, Supplier_Comments) VALUES ('$title', '$supplier_name', '$add1', '$add2', '$city', '$telephone', '$fax', '$email', '$web', '$comm') "); $noerror = "supplier details has been added to the database!"; } } // end of form handling ?> <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post"> <table> <tr id="sh5"> <td> Title:</td> <td><select name="custitle" size="1"> <option value="Mr." selected>Mr.</option> <option value="Mrs.">Mrs.</option> <option value="Ms.">Ms.</option> <option value="Rev.">Rev.</option> </select> </td> </tr> <tr id="sh8"> <td> Supplier Name:</td> <td><input type="text" size="35" name="supplier_name" value="<?php if(isset($_POST['submit']) && isset($error)){ echo $supplier_name; } ?>"> </td> </tr> <tr id="sh5"> <td> Address:</td> <td><input type="text" size="35" name="add1" value="<?php if(isset($_POST['submit']) && isset($error)){ echo $add1; } ?>"><br /> <input type="text" size="45" name="add2" value="<?php if(isset($_POST['submit']) && isset($error)){ echo $add2; } ?>"></td> </tr> <tr id="sh8"> <td> City:</td> <td><input type="text" size="25" name="city" value="<?php if(isset($_POST['submit']) && isset($error)){ echo $city; } ?>"></td> </tr> <tr id="sh5"> <td> Telephone:</td> <td><input type="text" size="30" name="telephone" value="<?php if(isset($_POST['submit']) && isset($error)){ echo $telephone; } ?>"> </tr> <tr id="sh8"> <td> Fax:</td> <td><input type="text" size="15" name="fax" value="<?php if(isset($_POST['submit']) && isset($error)){ echo $fax; } ?>"></td> </tr> <tr id="sh5"> <td> Email:</td> <td><input type="text" size="40" name="email" id="email" value="<?php if(isset($_POST['submit']) && isset($error)){ echo $email; } ?>"></td> </tr> <tr id="sh8"> <td> Website:</td> <td><input type="text" size="40" name="web" value="<?php if(isset($_POST['submit']) && isset($error)){ echo $web; } ?>"></td> </tr> <tr id="sh5"> <td> Comments:</td> <td><textarea cols="40" rows="4" name="comm"><?php if(isset($_POST['submit']) && isset($error)){ echo $comm; } ?></textarea></td> </tr> <tr> <td> </td> <td><input class="btn" type="submit" name="submit" value="Add Supplier"></td> </tr> </table> </form> </div> <div class="s40"> <p><strong>Add New Supplier<br> </strong>Use this form to add new supplier to the system.</p> <?php if(isset($error)){ echo "<div class=\"errordiv\">{$error}</div>"; } if(isset($noerror)){ echo "<div class=\"noerrordiv\">"; echo $noerror; echo "</div>"; } ?> </div> </div> <?php include("inc/page_footer.php"); ?>
Comments
Post a Comment