Location: PHPKode > projects > Phpgw Time Tracking Add On App > timetrack/customers.php
<?php
  /**************************************************************************\
  * phpgwtimetrack - phpGroupWare addon application                          *
  * http://phpgwtimetrack.sourceforge.net                                    *
  * Written by Robert Schader <hide@address.com>                         *
  * --------------------------------------------                             *
  *  This program is free software; you can redistribute it and/or modify it *
  *  under the terms of the GNU General Public License as published by the   *
  *  Free Software Foundation; either version 2 of the License, or (at your  *
  *  option) any later version.                                              *
  \**************************************************************************/

  /* $Id: customers.php,v 1.3 2001/01/08 21:28:17 rschader Exp $ */

  $phpgw_info["flags"]["enable_nextmatchs_class"] = "True";
  $phpgw_info["flags"]["currentapp"] = "timetrack";
  include("../header.inc.php");

  $t = new Template($phpgw_info["server"]["app_tpl"]);
  $t->set_file(array( "header"	=> "customers.tpl",
			       "row"		=> "customers.tpl",
			       "footer"	=> "customers.tpl" ));

  $t->set_block("header","row","footer");

  if (! $start)
     $start = 0;

  if ($order)
      $ordermethod = "order by $order $sort";
   else
      $ordermethod = "order by company_name,industry_type,status asc";

  if (! $sort)
     $sort = "desc";

  if ($query) {
     $querymethod = " where company_name like '%$query%' OR industry_type like '%$query%' OR status "
		        . "like '%$query%' ";
  }

  $phpgw->db->query("select count(*) from customers $querymethod");
  $phpgw->db->next_record();

  $total = $phpgw->db->f(0);
  $limit = $phpgw->nextmatchs->sql_limit($start);

  $t->set_var("bg_color",$phpgw_info["theme"]["bg_color"]);
  $t->set_var("th_bg",$phpgw_info["theme"]["th_bg"]);

  $t->set_var("left_next_matchs",$phpgw->nextmatchs->left("customers.php",$start,$total));
  $t->set_var("lang_customer_list",lang("customer list"));
  $t->set_var("right_next_matchs",$phpgw->nextmatchs->right("customers.php",$start,$total));

  $t->set_var("lang_company_name",$phpgw->nextmatchs->show_sort_order($sort,"company_name",$order,"customers.php",lang("company name")));
  $t->set_var("lang_industry_type",$phpgw->nextmatchs->show_sort_order($sort,"industry_type",$order,"customers.php",lang("industry type")));
  $t->set_var("lang_status",$phpgw->nextmatchs->show_sort_order($sort,"status",$order,"customers.php",lang("status")));

  $t->set_var("lang_edit",lang("Edit"));
  $t->set_var("lang_delete",lang("Delete"));
  $t->set_var("lang_view",lang("View"));

  $t->parse("out","header");

  $phpgw->db->query("select company_id,company_name,industry_type,status from customers $querymethod "
	             . "$ordermethod limit $limit");

  while ($phpgw->db->next_record()) {
    $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
    $t->set_var("tr_color",$tr_color);

    $company_name  = $phpgw->db->f("company_name");
    $industry_type = $phpgw->db->f("industry_type");
    $status = $phpgw->db->f("status");

    if (! $company_name)  $company_name  = '&nbsp;';
    if (! $industry_type) $industry_type = '&nbsp;';
    if (! $status) $status = '&nbsp;';

    $t->set_var("row_company_name",$company_name);
    $t->set_var("row_industry_type",$industry_type);
    $t->set_var("row_status",$status);
    $t->set_var("row_edit",'<a href="'.$phpgw->link("editcustomer.php","cid="
				  . $phpgw->db->f("company_id")) . '"> ' . lang("Edit") . ' </a>');

    $t->set_var("row_delete",'<a href="' . $phpgw->link("deletecustomer.php",'cid='
			 	  . $phpgw->db->f("company_id")) . '"> '.lang("Delete").' </a>');

    $t->set_var("row_view",'<a href="' . $phpgw->link("viewcustomer.php", "cid="
				 . $phpgw->db->f("company_id")) . '"> ' . lang("View") . ' </a>');

    if ($phpgw->db->num_rows() == 1) {
       $t->set_var("output","");
    }
    if ($phpgw->db->num_rows() != ++$i) {
       $t->parse("output","row",True);
    }

  }

  $t->set_var("actionurl",$phpgw->link("newcustomer.php"));
  $t->set_var("lang_add",lang("add"));
  $t->set_var("lang_search",lang("search"));
  $t->set_var("queryurl",$phpgw->link("customers.php"));

  $t->pparse("out","footer");

  $phpgw->common->phpgw_footer();
Return current item: Phpgw Time Tracking Add On App