Location: PHPKode > projects > IRMA - Asset Inventory and Job Tracking > irma-1.0.6/includes/support-contracts/functions.php
<?php 

include_once(INCDIR . "/includes_support_contracts.php");

function listSupportContracts() {

    print <<<EOF
<div align="center">
</div>

EOF;

}

function showSupportSupplierForm($id) {

    $supplier = new SupportSupplier();

    if ($id > 0) {
        $supplier->getFromDB($id);
    }

    $label = "Add new Supplier";
    $action = 'add';

    $name = 'Add New Supplier';

    if ($supplier->name != "") {
        $name = $supplier->name;
        $label = 'Update';
        $action = 'update';
    }

    print <<<EOF
<div align="center">
<h2>{$name}</h2>
<form method="POST" action="{$_SERVER['PHP_SELF']}">
<table border="0" cellpadding="3" cellspacing="0">
  <tr>
    <td>Name</td>
    <td>
      <input type="text" name="name" length="200" 
             value="{$supplier->name}">
    </td>
  </tr>
  <tr>
    <td>Address</td>
    <td>
      <textarea cols=80 rows="10" name="address">{$supplier->address}</textarea>
    </td>
  </tr>
  <tr>
    <td>Phone</td>
    <td>
      <input type="text" name="phone" length="200" 
             value="{$supplier->phone}">
    </td>
  </tr>
  <tr>
    <td>FAX</td>
    <td>
      <input type="text" name="fax" length="200" 
             value="{$supplier->fax}">
    </td>
  </tr>
  <tr>
    <td>Comments</td>
    <td>
      <textarea cols=80 rows="10" 
                name="comments">{$supplier->comments}</textarea>
    </td>
  </tr>
  <tr>
    <td align="center" colspan="2">
      <input type="hidden" name="support_supplier_id" 
             value="{$supplier->support_supplier_id}">
      <input type="hidden" name="action" value="{$action}">
      <input type="submit" name="submit" value="{$label}">
    </td>
  </tr>
</table>
</form>

</div>

EOF;

}

function addSupportSupplier($input) {

    $supplier = new SupportSupplier();
    $supplier->name = $input['name'];
    $supplier->address = $input['address'];
    $supplier->phone = $input['phone'];
    $supplier->fax = $input['fax'];
    $supplier->comments = $input['comments'];

    $supplier->addToDB();
}

function updateSupportSupplier($input = array()) {

    $supplier = new SupportSupplier();
    $supplier->support_supplier_id = $input['support_supplier_id'];
    $supplier->name = $input['name'];
    $supplier->address = $input['address'];
    $supplier->phone = $input['phone'];
    $supplier->fax = $input['fax'];
    $supplier->comments = $input['comments'];

    $supplier->updateInDB(array_keys($input));
}

function deleteSupportSupplier($id) {

    $supplier = new SupportSupplier();
    $supplier->deleteFromDB($id);

}

function listSupportSuppliers() {

    print <<<EOF
<div align="center">

<h2>Support Suppliers</h2>

<h3><a href="supplier.php?action=new">Add Supplier</a></h3>

<table border="0" cellpadding="3" cellspacing="0">
<tr>
  <th>Name</th>
  <th>Phone</th>
  <th>FAX</th>
  <th>Action</th>
</tr>

EOF;

    foreach (SupportSupplier::getAllSuppliers() as $supplier) {

        $view_link = "supplier.php?action=view&id=" . 
                     $supplier->support_supplier_id;

        $delete_link = "supplier.php?action=delete&id=" .
                       $supplier->support_supplier_id;

        print <<<EOF
<tr>
  <td><a href="{$view_link}">{$supplier->name}</a></td>
  <td>{$supplier->phone}</td>
  <td>{$supplier->fax}</td>
  <td align="center">
    <b><a href="{$view_link}">View</a></b> | 
    <b><a href="{$delete_link}">Delete</a></b>
  </td>
</tr>

EOF;

    }

    print <<<EOF
</table>
</div>

EOF;

}

function listSupportContractContacts($post = array()) {

    print <<<EOF
<div align="center">
</div>

EOF;

}

?>
Return current item: IRMA - Asset Inventory and Job Tracking