[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/modules/system/ -> billingcode.php (source)

   1  <?php /* $Id: billingcode.php 137 2008-04-04 16:12:02Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/system/billingcode.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  ##
   7  ## add or edit a user preferences
   8  ##
   9  $company_id = 0;
  10  $company_id = isset($_REQUEST['company_id']) ? w2PgetParam($_REQUEST, 'company_id', 0) : 0;
  11  // Check permissions
  12  $perms = &$AppUI->acl();
  13  if (!$perms->checkModule('system', 'edit')) {
  14      $AppUI->redirect('m=public&a=access_denied');
  15  }
  16  
  17  $q = new DBQuery;
  18  $q->addTable('billingcode', 'bc');
  19  $q->addQuery('billingcode_id, billingcode_name, billingcode_value, billingcode_desc, billingcode_status');
  20  $q->addOrder('billingcode_name ASC');
  21  //$q->addWhere('bc.billingcode_status = 0');
  22  $q->addWhere('company_id = ' . (int)$company_id);
  23  $billingcodes = $q->loadList();
  24  $q->clear();
  25  
  26  $q = new DBQuery;
  27  $q->addTable('companies', 'c');
  28  $q->addQuery('company_id, company_name');
  29  $q->addOrder('company_name ASC');
  30  $company_list = $q->loadHashList();
  31  $company_list[0] = $AppUI->_('Select Company');
  32  $q->clear();
  33  
  34  $company_name = $company_list[$company_id];
  35  
  36  function showcodes(&$a) {
  37      global $AppUI, $company_id;
  38  
  39      $alt = htmlspecialchars($a['billingcode_desc']);
  40      $s = '
  41  <tr>
  42      <td width=40>
  43          <a href="?m=system&amp;a=billingcode&amp;company_id=' . $company_id . '&amp;billingcode_id=' . $a['billingcode_id'] . '" title="' . $AppUI->_('edit') . '">
  44              <img src="' . w2PfindImage('icons/stock_edit-16.png') . '" border="0" alt="Edit" /></a>';
  45  
  46      if ($a['billingcode_status'] == 0)
  47          $s .= '<a href="javascript:delIt2(' . $a['billingcode_id'] . ');" title="' . $AppUI->_('delete') . '">
  48              <img src="' . w2PfindImage('icons/stock_delete-16.png') . '" border="0" alt="Delete" /></a>';
  49  
  50      $s .= '
  51      </td>
  52      <td align="left">&nbsp;' . $a['billingcode_name'] . ($a['billingcode_status'] == 1 ? ' (deleted)' : '') . '</td>
  53      <td nowrap="nowrap" align="center">' . $a['billingcode_value'] . '</td>
  54      <td nowrap="nowrap">' . $a['billingcode_desc'] . '</td>
  55  </tr>';
  56      echo $s;
  57  }
  58  
  59  $titleBlock = new CTitleBlock('Edit Billing Codes', 'myevo-weather.png', $m, $m . '.' . $a);
  60  $titleBlock->addCrumb('?m=system', 'system admin');
  61  $titleBlock->show();
  62  ?>
  63  <script type="text/javascript" language="javascript">
  64  <!--
  65  function submitIt(){
  66      var form = document.changeuser;
  67      form.submit();
  68  }
  69  
  70  function changeIt() {
  71      var f=document.changeMe;
  72      var msg = '';
  73      f.submit();
  74  }
  75  
  76  
  77  function delIt2(id) {
  78      document.frmDel.billingcode_id.value = id;
  79      document.frmDel.submit();
  80  }
  81  -->
  82  </script>
  83  
  84  <form name="frmDel" action="./index.php?m=system" method="post">
  85      <input type="hidden" name="dosql" value="do_billingcode_aed" />
  86      <input type="hidden" name="del" value="1" />
  87      <input type="hidden" name="company_id" value="<?php echo $company_id; ?>" />
  88      <input type="hidden" name="billingcode_id" value="" />
  89  </form>
  90  <table width="100%" border="0" cellpadding="1" cellspacing="1" class="std">
  91  <tr>
  92      <td>
  93      <form name="changeMe" action="./index.php?m=system&amp;a=billingcode" method="post">
  94          <?php echo arraySelect($company_list, 'company_id', 'size="1" class="text" onchange="changeIt();"', $company_id, false); ?>
  95      </form>
  96      </td>
  97  </tr>
  98  <tr>
  99      <th width="40">&nbsp;
 100      <form name="changeuser" action="./index.php?m=system" method="post">
 101          <input type="hidden" name="dosql" value="do_billingcode_aed" />
 102          <input type="hidden" name="del" value="0" />
 103          <input type="hidden" name="company_id" value="<?php echo $company_id; ?>" />
 104          <input type="hidden" name="billingcode_status" value="0" />
 105      </th>
 106      <th><?php echo $AppUI->_('Billing Code'); ?></th>
 107      <th><?php echo $AppUI->_('Value'); ?></th>
 108      <th><?php echo $AppUI->_('Description'); ?></th>
 109  </tr>
 110  
 111  <?php
 112  foreach ($billingcodes as $code) {
 113      showcodes($code);
 114  }
 115  
 116  if (isset($_GET['billingcode_id'])) {
 117      $q->addQuery('*');
 118      $q->addTable('billingcode');
 119      $q->addWhere('billingcode_id = ' . (int)w2PgetParam($_GET, 'billingcode_id', 0));
 120      list($obj) = $q->loadList();
 121  
 122      echo '
 123  <tr>
 124      <td>&nbsp;<input type="hidden" name="billingcode_id" value="' . w2PgetParam($_GET, 'billingcode_id', 0) . '" /></td>
 125      <td><input type="text" class="text" name="billingcode_name" value="' . $obj['billingcode_name'] . '" /></td>
 126      <td><input type="text" class="text" name="billingcode_value" value="' . $obj['billingcode_value'] . '" /></td>
 127      <td><input type="text" class="text" name="billingcode_desc" value="' . $obj['billingcode_desc'] . '" /></td>
 128  </tr>';
 129  } else {
 130  ?>
 131  <tr>
 132      <td>&nbsp;</td>
 133      <td><input type="text" class="text" name="billingcode_name" value="" /></td>
 134      <td><input type="text" class="text" name="billingcode_value" value="" /></td>
 135      <td><input type="text" class="text" name="billingcode_desc" value="" /></td>
 136  </tr>
 137  <?php } ?>
 138  
 139  <tr>
 140      <td align="left">
 141          <input class="button"  type="button" value="<?php echo $AppUI->_('back'); ?>" onclick="javascript:history.back(-1);" />
 142      </td>
 143      <td colspan="3" align="right">
 144          <input class="button" type="button" value="<?php echo $AppUI->_('submit'); ?>" onclick="submitIt()" />
 145      </td>
 146  </tr>
 147  </table>
 148  </form>


Generated: Thu Jan 8 03:00:03 2009 Cross-referenced by PHPXref 0.7