/** * retourne la liste de toutes les périodes * * @return String $periodes */ public function getAllPeriod() { $txt = new ComplexData(array()); $res = $this->db->query("SELECT per_id, per_name FROM t_period_per WHERE per_name != '' AND per_removed = '0'", array()); while ($don = $this->db->fetchArray($res)) { $txt->addLine(array($don['per_id'], $don['per_name'])); } return $txt->csvArrays(); }
/** * Renvoyer la liste des types de recharges. * * @param String $type * @return String $csv */ public function getTypeRecharge($type = '') { $txt = new ComplexData(array()); if ($type == '') { $res = $this->db->query("SELECT rty_id, rty_name FROM t_recharge_type_rty WHERE rty_removed = '0' ORDER BY rty_id ASC;"); } else { $res = $this->db->query("SELECT rty_id, rty_name FROM t_recharge_type_rty WHERE rty_removed = '0' AND rty_type = '%s' ORDER BY rty_id ASC;", array($type)); } if ($this->db->affectedRows() >= 1) { while ($don = $this->db->fetchArray($res)) { $txt->addLine(array($don['rty_id'], $don['rty_name'])); } return $txt->csvArrays(); } else { return 400; } }
/** * donne les points utilisables par une fundation pour faire sa tambouille * @return String $csvGroups */ public function getAvailablePoints() { $rtn = new ComplexData(); $req = $this->db->query("SELECT poi_id, poi_name FROM t_point_poi WHERE poi_removed = '0';"); while ($don = $this->db->fetchArray($req)) { $poi = new Point($don['poi_id']); $rtn->addLine(array($don['poi_id'], $poi->getName())); } return $rtn->csvArrays(); }
/** * Récupérer un csv du panier. * * @return int $state */ public function getCartCsv() { $txt = new ComplexData(array()); foreach ($this->Cart as $key => $value) { $txt->addLine(array($value['name'], $value['quantity'], $value['credit'])); } return $txt->csvArrays(); }
/** * Retourne un csv qui contient les id_fundation, id_point en fonction de ses droits * @param String $droit [optional] * @return String $txt */ public function getDroits($droit = '') { if (isset($this->user)) { $txt = new ComplexData(array()); if ($droit == '') { foreach ($this->user->getDroits() as $don) { $txt->addLine(array($don['droit'], $don['fundation']->getId(), $don['fundation']->getName(), $don['id_point'])); } } else { foreach ($this->user->getDroits() as $i => $don) { $key = in_array($droit, $don); if ($key) { $txt->addLine(array($don['fundation']->getId(), $don['fundation']->getName(), $don['id_point'])); } } } return $txt->csvArrays(); } else { return 409; } }
/** * Fonction qui renvoie les ventes entre 2 dates * * @param int $date_start * @param int $date_end * @return string $csv */ public function getPurchase($date_start, $date_end) { if ($this->User->isBuckuttTrezo() != 1) { return 400; } $txt = new ComplexData(array()); $res = $this->db->query("SELECT fun_name, sum(pur_price) AS total, poi_name FROM t_purchase_pur pur, t_fundation_fun fun, t_point_poi poi WHERE pur.poi_id = poi.poi_id AND pur.fun_id = fun.fun_id AND pur.pur_removed = '0' AND UNIX_TIMESTAMP(pur.pur_date) >= '%u' AND UNIX_TIMESTAMP(pur.pur_date) < '%u' GROUP BY pur.fun_id ORDER BY fun.fun_name", array($date_start, $date_end)); if ($this->db->affectedRows() >= 1) { while ($don = $this->db->fetchArray($res)) { $txt->addLine(array($don['fun_name'], $don['total'], $don['poi_name'])); } return $txt->csvArrays(); } else { return 400; } }