Exemple #1
0
 public static function get_list($_FORM = array())
 {
     $filter = productSale::get_list_filter($_FORM);
     $debug = $_FORM["debug"];
     $debug and print "\n<pre>_FORM: " . print_r($_FORM, 1) . "</pre>";
     $debug and print "\n<pre>filter: " . print_r($filter, 1) . "</pre>";
     if (is_array($filter) && count($filter)) {
         $f = " WHERE " . implode(" AND ", $filter);
     }
     $f .= " ORDER BY IFNULL(productSaleDate,productSaleCreatedTime)";
     $db = new db_alloc();
     $query = prepare("SELECT productSale.*, project.projectName, client.clientName\n                        FROM productSale \n                   LEFT JOIN client ON productSale.clientID = client.clientID\n                   LEFT JOIN project ON productSale.projectID = project.projectID\n                    " . $f);
     $db->query($query);
     $statii = productSale::get_statii();
     $people =& get_cached_table("person");
     $rows = array();
     while ($row = $db->next_record()) {
         $productSale = new productSale();
         $productSale->read_db_record($db);
         $row["amounts"] = $productSale->get_amounts();
         $row["statusLabel"] = $statii[$row["status"]];
         $row["salespersonLabel"] = $people[$row["personID"]]["name"];
         $row["creatorLabel"] = $people[$row["productSaleCreatedUser"]]["name"];
         $row["productSaleLink"] = $productSale->get_link();
         $rows[] = $row;
     }
     return (array) $rows;
 }