Actually a customer in this system refers to a site / construction project and therefore if a same customer having more than one construction site, all those sites need to enter as a separate customer. You can view customer details in edit individual records by going to "Customers" menu and selecting "View Edit Customers".
In this location you can create the BOQ (Bills of Quantities) for each site. BOQ details are stored in the "boq" database table.
Source code of "view_edit_customers.php" page:
<?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="s100"> <div class="boxtitle">Customers</div> <table width="99%" cellpadding="3px" cellspacing="1px"> <tr id="headrow"> <td>ID</td> <td>Name</td> <td>Address</td> <td>Telephone</td> <td>Fax</td> <td>Actions</td> </tr> <?php $q = mysql_query("SELECT * FROM customers"); while($r = mysql_fetch_assoc($q)){ echo "<tr>"; echo "<td id=\"sh4\">{$r['Customer_ID']}</td>"; echo "<td id=\"sh3\">{$r['Customer_Title']} {$r['Customer_Name']}</td>"; echo "<td id=\"sh4\">{$r['Customer_Address']}, {$r['Customer_Address_2']}, {$r['Customer_City']}</td>"; echo "<td id=\"sh3\">{$r['Customer_Telephone']}</td>"; echo "<td id=\"sh4\">{$r['Customer_Fax']}</td>"; echo "<td id=\"sh3\"> <a href=\"edit_customer.php?id={$r['Customer_ID']}\">Edit</a> | <a href=\"edit_boq.php?id={$r['Customer_ID']}\">BOQ</a> </td>"; echo "</tr>"; } ?> </table> </div> </div> <?php include("inc/page_footer.php"); ?>
Source code of "edit_boq.php" file:
<?php include("inc/page_header.php"); ?> <?php if(check('Add/Edit Customers') != 'Valid'){ header("Location: sys_home.php?pre=error"); ob_end_flush(); } if(isset($_GET['id'])){ $customer_id = $_GET['id']; }else{ header("Location: sys_home.php?pre=error"); ob_end_flush(); exit(); } ?> <div class="wrapper"> <div class="s100"> <div class="boxtitle">Edit / Update BOQ ::: <?php echo customer_name($customer_id); ?></div> <?php if(isset($_POST['submit'])){ $c = mysql_query("SELECT Item_Code FROM items"); while($d = mysql_fetch_assoc($c)){ $item_code = $d['Item_Code']; $post_qty = 'qty-'.$item_code; $qty = $_POST[$post_qty]; if($qty >= 0){ // check for records $qx = mysql_query("SELECT * FROM boq WHERE boq_customer = '$customer_id' AND boq_item = '$item_code'"); if(mysql_num_rows($qx) > 0){ // update mysql_query("UPDATE boq SET boq_qty = '$qty' WHERE boq_customer = '$customer_id' AND boq_item = '$item_code'"); }else{ // insert mysql_query("INSERT INTO boq (boq_customer, boq_item, boq_qty) VALUES ('$customer_id', '$item_code', '$qty')"); } $noerror = "Item details has been updated in the BOQ"; }else{ $error = "Please enter a valid Qty"; } } } if(isset($error)){ echo "<div class=\"errordiv\">{$error}</div>"; } if(isset($noerror)){ echo "<div class=\"noerrordiv\">"; echo $noerror; echo "</div>"; } ?> <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> <table width="99%" cellpadding="3px" cellspacing="1px"> <tr id="headrow"> <td>ID</td> <td>Product Name</td> <td>Qty</td> </tr> <?php $c = mysql_query("SELECT * FROM categories"); while($d = mysql_fetch_assoc($c)){ $cat_id = $d['Category_ID']; $cat_name = $d['Category_Name']; echo "<tr><td colspan=\"3\">{$cat_name}</td></tr>"; $q = mysql_query("SELECT * FROM items WHERE Item_Category = '$cat_id'"); while($r = mysql_fetch_assoc($q)){ $boq_value = boq_value($customer_id, $r['Item_Code']); echo "<tr>"; echo "<td id=\"sh4\">{$r['Item_Part_No']}</td>"; echo "<td id=\"sh3\">{$r['Item_Name']}</td>"; echo "<td id=\"sh4\"> <input type=\"text\" name=\"qty-{$r['Item_Code']}\" value=\"{$boq_value}\"> {$r['Unit']} </td>"; echo "</tr>"; } } ?> </table> <p align="right"><input type="submit" value="Submit" name="submit"></p> </form> </div> </div> <?php include("inc/page_footer.php"); ?>
Comments
Post a Comment