home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / dotproject / modules / companies / index.php < prev    next >
Encoding:
PHP Script  |  2004-01-15  |  3.3 KB  |  99 lines

  1. <?php /* COMPANIES $Id: index.php,v 1.39 2004/01/15 17:55:45 gregorerhardt Exp $ */
  2. $AppUI->savePlace();
  3.  
  4. // retrieve any state parameters
  5. if (isset( $_GET['orderby'] )) {
  6.     $AppUI->setState( 'CompIdxOrderBy', $_GET['orderby'] );
  7. }
  8. $orderby = $AppUI->getState( 'CompIdxOrderBy' ) ? $AppUI->getState( 'CompIdxOrderBy' ) : 'company_name';
  9.  
  10. // load the company types
  11. $types = dPgetSysVal( 'CompanyType' );
  12.  
  13. // get any records denied from viewing
  14. $obj = new CCompany();
  15. $deny = $obj->getDeniedRecords( $AppUI->user_id );
  16.  
  17. // Company search by Kist
  18. $search_string = dPgetParam( $_POST, 'search_string', '' );
  19.  
  20. // retrieve list of records
  21. /*
  22.  The following query is actually made at vw_companies.php
  23.  It was excuted twice, so I commented out this block
  24.  - jcgonz
  25.  
  26. $sql = "
  27. SELECT company_id, company_name, company_type, company_description,
  28.     count(distinct projects.project_id) as countp, count(distinct projects2.project_id) as inactive,
  29.     user_first_name, user_last_name
  30. FROM permissions, companies
  31. LEFT JOIN projects ON companies.company_id = projects.project_company and projects.project_active <> 0
  32. LEFT JOIN users ON companies.company_owner = users.user_id
  33. LEFT JOIN projects AS projects2 ON companies.company_id = projects2.project_company AND projects2.project_active = 0
  34. WHERE permission_user = $AppUI->user_id
  35.     AND permission_value <> 0
  36.     AND (
  37.         (permission_grant_on = 'all')
  38.         OR (permission_grant_on = 'companies' and permission_item = -1)
  39.         OR (permission_grant_on = 'companies' and permission_item = company_id)
  40.         )
  41. " . (count($deny) > 0 ? 'and company_id not in (' . implode( ',', $deny ) . ')' : '')
  42.  . "GROUP BY company_id
  43.     ORDER BY $orderby";
  44.  
  45. $rows = db_loadList( $sql );
  46. */
  47.  
  48. $search_string = dPformSafe($search_string, true);
  49.  
  50. // setup the title block
  51. $titleBlock = new CTitleBlock( 'Companies', 'handshake.png', $m, "$m.$a" );
  52. $titleBlock->addCell("<strong>".$AppUI->_('Search').":</strong>");
  53. $titleBlock->addCell("<form name='searchform' action='?m=companies&search_string=$search_string' method='post'>
  54.                       <input type='text' name='search_string' value='$search_string' />
  55.                       </form>");
  56. if ($canEdit) {
  57.     $titleBlock->addCell(
  58.         '<input type="submit" class="button" value="'.$AppUI->_('new company').'">', '',
  59.         '<form action="?m=companies&a=addedit" method="post">', '</form>'
  60.     );
  61. }
  62. $titleBlock->show();
  63.  
  64. if (isset( $_GET['tab'] )) {
  65.     $AppUI->setState( 'CompaniesIdxTab', $_GET['tab'] );
  66. }
  67. $companiesTypeTab = defVal( $AppUI->getState( 'CompaniesIdxTab' ), 0 );
  68.  
  69. /*function getCompanyTypeID($type) {
  70.     global $types;
  71.     $arr = array_keys($types, $type);
  72.     return $arr[0];
  73. }
  74.  
  75. $tabTypes = array();
  76. foreach($types as $type_id => $type){
  77.     $tabTypes[] = $type_id;
  78. }
  79. */
  80. // $tabTypes = array(getCompanyTypeID('Client'), getCompanyTypeID('Supplier'), 0);
  81. $companiesType = $companiesTypeTab;
  82.  
  83. $tabBox = new CTabBox( "?m=companies", "{$AppUI->cfg['root_dir']}/modules/companies/", $companiesTypeTab );
  84. foreach($types as $type_name){
  85.     $tabBox->add('vw_companies', $type_name);
  86. }
  87.  
  88. // Only display the All option in tabbed view, in plain mode it would just repeat everything else
  89. // already in the page
  90. if ( $companiesTypeTab != -1 ) $tabBox->add('vw_companies', 'All Companies');
  91.  
  92. /*$tabBox->add( 'vw_companies', 'Clients' );
  93. $tabBox->add( 'vw_companies', 'Suppliers' );
  94. $tabBox->add( 'vw_companies', 'All Companies' );
  95. */
  96.  
  97. $tabBox->show();
  98. ?>
  99.