public function getList($order, $critere, $debut, $nbres) { $query = $this->getRequest('list', $order, $critere, $debut, $nbres); $resul = $this->query($query); $retour = array(); while ($resul && ($row = $this->fetch_object($resul))) { $thisClient = array(); $thisClient['ref'] = $row->ref; $thisClient['entreprise'] = $row->entreprise; $thisClient['nom'] = $row->nom; $thisClient['prenom'] = $row->prenom; $thisClient['email'] = $row->email; $commande = new Commande(); $devise = new Devise(); $querycom = "SELECT id FROM {$commande->table} WHERE client={$row->id} AND statut NOT IN(" . Commande::NONPAYE . "," . Commande::ANNULE . ") ORDER BY date DESC LIMIT 0,1"; $resulcom = $commande->query($querycom); if ($commande->num_rows($resulcom) > 0) { $idcom = $commande->get_result($resulcom, 0, "id"); $commande->charger($idcom); $devise->charger($commande->devise); $thisClient['date'] = strftime("%d/%m/%Y %H:%M:%S", strtotime($commande->date)); $thisClient['somme'] = formatter_somme($commande->total(true, true)) . ' ' . $devise->symbole; } else { $thisClient['date'] = ''; $thisClient['somme'] = ''; } $retour[] = $thisClient; } return $retour; }
/** * Mettre à jour les taux de conversions par rapport à l'Euro */ public function refresh() { $file_contents = file_get_contents('http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml'); $devise = new Devise(); if ($file_contents && ($sxe = new SimpleXMLElement($file_contents))) { foreach ($sxe->Cube[0]->Cube[0]->Cube as $last) { $devise->query("UPDATE {$devise->table} SET taux='" . $devise->escape_string($last["rate"]) . "' WHERE code='" . $devise->escape_string($last["currency"]) . "'"); } } redirige("devise.php"); }
/** * Retourne l'ID de la devise par défaut. Pour améliorer les perfs, on cache cet ID * dans une variable statique. */ public function get_id_devise_defaut() { if ($this->id_devise_defaut === false) { $devise = new Devise(); if ($devise->charger_defaut()) { $this->id_devise_defaut = $devise->id; } else { $this->id_devise_defaut = 1; } } return $this->id_devise_defaut; }
/** * Supprimer une devise existante */ public function supprimer() { if ($this->id == "") { throw new TheliaAdminException("Devise not found", TheliaAdminException::DEVISE_NOT_FOUND); } $devise = new Devise($this->id); parent::delete(); ActionsModules::instance()->appel_module("suppdevise", $devise); $this->redirect(); }
public static function getDeviseById($bdd, $id) { $Devise = new Devise(); $devise = $bdd->prepare("SELECT * FROM devise WHERE id = :did LIMIT 1"); $devise->execute(array(':did' => $id)); while ($array = $devise->fetch()) { $Devise->setId($array['id']); $Devise->setName($array['name']); $Devise->setSigne($array['signe']); $Devise->setTaux($array['taux']); } return $Devise; }
function liste_clients($order, $critere, $debut) { $i = 0; $client = new Client(); $query = "select * from {$client->table} order by {$critere} {$order} limit {$debut},20"; $resul = $client->query($query); while ($resul && ($row = $client->fetch_object($resul))) { $fond = "ligne_" . ($i++ % 2 ? "claire" : "fonce") . "_rub"; $commande = new Commande(); $devise = new Devise(); $querycom = "select id from {$commande->table} where client={$row->id} and statut not in(" . Commande::NONPAYE . "," . Commande::ANNULE . ") order by date DESC limit 0,1"; $resulcom = $commande->query($querycom); $existe = 0; if ($commande->num_rows($resulcom) > 0) { $existe = 1; $idcom = $commande->get_result($resulcom, 0, "id"); $commande->charger($idcom); $devise->charger($commande->devise); $date = strftime("%d/%m/%y %H:%M:%S", strtotime($commande->date)); } $creation = strftime("%d/%m/%y %H:%M:%S", strtotime($row->datecrea)); ?> <ul class="<?php echo $fond; ?> "> <li style="width:122px;"><?php echo $row->ref; ?> </li> <li style="width:110px;"><?php echo $creation; ?> </li> <li style="width:143px;"><?php echo $row->entreprise; ?> </li> <li style="width:243px;"><?php echo $row->nom; ?> <?php echo $row->prenom; ?> </li> <li style="width:110px;"><?php if ($existe) { echo $date; } ?> </li> <li style="width:63px;"><?php if ($existe) { echo formatter_somme($commande->total(true, true)) . ' ' . $devise->symbole; } ?> </li> <li style="width:40px;"><a href="client_visualiser.php?ref=<?php echo $row->ref; ?> " class="txt_vert_11"><?php echo trad('editer', 'admin'); ?> </a></li> <li style="width:25px; text-align:center;"><a href="#" onclick="confirmSupp('<?php echo $row->ref; ?> ')"><img src="gfx/supprimer.gif" width="9" height="9" border="0" /></a></li> </ul> <?php } }
/** * Retourne une liste des devises */ public function lister() { $devise = new Devise(); return $devise->query_liste("select * from {$devise->table}", "Devise"); }
public static function getCoutOfUser($bdd) { $allUser = User::getAllUser($bdd); $couts = []; foreach ($allUser as $user) { $userNotes = Note::getNotesByUser($bdd, $user['id']); $uDevise = Devise::getDeviseById($bdd, $user['devise_id']); $totalNote = 0; foreach ($userNotes as $note) { $totalNote += Note::getMontantTotal($bdd, $note['id'], $uDevise->getTaux()); } $couts[] = ["username" => $user['login'], "total" => $totalNote]; } usort($couts, function ($a, $b) { if ($a['total'] == $b['total']) { return 0; } return $a['total'] < $b['total'] ? 1 : -1; }); return array_slice($couts, 0, 10); }
<ul> <?php //boucle des frais de la note foreach ($allFrais as $frais) { $categorie = CategorieFrais::getCategorieById($bdd, $frais['categorie_id']); ?> <li class="frais-<?php echo $frais['id'] ?>"> <div class="infos-frais"> <img class="img-frais" src="<?php echo $basePath . 'image/uploads/' . $frais['image'] ?>"/> <span><?php echo $frais['description'] ?></span> </div> <div class="total"> <?php $fdevise = Devise::getDeviseById($bdd, $frais['devise_id']); echo $frais['montant'] . ' ' . $fdevise->getSigne() . '<br/>'; echo '(<span class="total-frais">' . Devise::getValueOfChangedDevise($frais['montant'],$fdevise->getTaux(),$devise->getTaux()) . '</span> ' . $devise->getSigne() . ')'; ?><br/> <span><?php echo date("d-m-Y", strtotime($frais['date'])); ?></span><br/> <span class="categorie-frais"><?php echo $categorie->getName(); ?></span> </div> <div class="actions-frais"> <button class="frais-<?php echo $frais['id'] ?> btn btn-danger" data-note="note-<?php echo $note['id']; ?>">supprimer</button> <a class="btn btn-default" href="<?php echo $basePath . '?page=frais&id=' . $frais['id']; ?>">editer</a> </div> </li> <?php } //fin boucle des frais ?> </ul> </div> </div>
<div> <form action="" method="POST" enctype="multipart/form-data"> <span class="bandblue">Votre nom</span> : <?php echo $sessionUser->getName(); ?><br/> <span class="bandblue">Votre Login</span> : <?php echo $sessionUser->getLogin(); ?><br/> <span class="bandblue">Votre Email</span> : <input class = "formulaireEmail formprofil" type="text" name="nouveauMail" value='<?php echo $sessionUser->getEmail(); ?>'/> <input class = "btnmodif" type="submit" name="changementEmailUser" value="Modifier"/> <br/> <?php $Devise = new Devise(); $Devise = Devise::getDeviseById($bdd,$sessionUser->getDevise()); ?> <span class="bandblue">Votre devise actuelle</span> : <select class = "formulaire formulaireDevise formprofil" name="devise_id"> <?php $reponseDevise = Devise::getAllDevise($bdd); while($donnee = $reponseDevise->fetch()) { ?> <option value="<?php echo $donnee['id'];?>" <?php if($sessionUser->getDevise() == $donnee['id']){echo $selected; } ?>><?php echo $donnee['name'];?></option> <?php } ?> </select> <input class = "btnmodif" type="submit" name="changementDeviseUser" value="Modifier"/> </form> </div> <div style="text-align: center"> <br/><br/> <h3><strong>Modification du mot de passe</strong></h3><br/>
$color = 30; foreach ($allCategorie as $categorie) { $categorieCout = Frais::getCoutByCategorieId($bdd, $categorie["id"]); $fdevise = Devise::getDeviseById($bdd, $categorieCout['devise_id'])->getTaux(); $data["categorie"]["labels"][] = $categorie["name"]; $data["categorie"]["cout"][] = Devise::getValueOfChangedDevise($categorieCout["totalCat"], $fdevise, $userDevise); $data["categorie"]["all"][] = ["value" => Devise::getValueOfChangedDevise($categorieCout["totalCat"], $fdevise, $userDevise), "color" => "rgb(" . $color . ", " . $color * 2 . ", " . $color / 2 . ")", "highlight" => "rgb(" . ($color + 15) . ", " . ($color * 2 + 15) . ", " . ($color + 15) . ")", "label" => $categorie["name"]]; $color += 30; } while ($i <= 12) { $coutMois = Frais::getCoutParMois($bdd, $i); $fdevise = Devise::getDeviseById($bdd, $coutMois['devise_id'])->getTaux(); if ($coutMois == NULL) { $coutMois = 0; } $data["mois"]["cout"][] = Devise::getValueOfChangedDevise($coutMois["totalMois"], $fdevise, $userDevise); $i++; } foreach ($userCouts as $uCout) { $data["user"]["login"][] = $uCout["username"]; $data["user"]["cout"][] = $uCout["total"]; } break; default: break; } } } } // on retourne la reponse json echo json_encode($data);
<a href="<?php echo $basePath ?>?page=admin§ion=user&action=adduser" class="btn btn-primary">Ajouter un utilisateur</a> <br/><br/> <div class="admin-user"> <table> <tr> <th>Nom</th> <th>Login</th> <th>Mail</th> <th>Role</th> <th>Devise</th> <th>Actions</th> </tr> <?php foreach ($listUser as $user) { ?> <tr class="tr-user-<?php echo $user['id']; ?>"> <td><?php echo $user['name']; ?></td> <td><?php echo $user['login']; ?></td> <td><?php echo $user['mail']; ?></td> <td><?php echo Role::getRoleById($bdd, $user['role_id'])->getName(); ?></td> <td><?php echo Devise::getDeviseById($bdd, $user['devise_id'])->getName(); ?></td> <td><button class="user-<?php echo $user['id']; ?> btn btn-danger">supprimer</button> <a class="btn btn-default" href="<?php echo $basePath ."?page=user&id=" . $user['id']; ?>">editer</a></td> </tr> <?php } ?> </table> </div> <br/> <a href="<?php echo $basePath ?>?page=admin§ion=user&action=adduser" class="btn btn-primary">Ajouter un utilisateur</a>
function boucleDevise($texte, $args) { // récupération des arguments $produit = lireTag($args, "produit", "int"); $id = lireTag($args, "id", "int_list"); $somme = lireTag($args, "somme", "float"); $exclusion = lireTag($args, "exclusion", "int_list"); $search = ""; $limit = ""; $res = ""; if ($somme == "") { $somme = 0; } $prod = new Produit(); if (!empty($produit)) { $prod->charger_id($produit); } if ($id != "") { $search .= " and id in({$id})"; } if ($exclusion != "") { $search .= " and id not in({$exclusion})"; } $url = preg_replace('/[\\&\\?]*devise=[0-9]+/', '', url_page_courante()); $url .= strstr($url, '?') == false ? '?' : '&'; $devise = new Devise(); $query = "select * from {$devise->table} where 1 {$search} {$limit}"; $resul = CacheBase::getCache()->query($query); //FIX : test d'existence de la session if (!isset($_SESSION["navig"])) { $_SESSION["navig"] = new Navigation(); } if (!empty($resul)) { foreach ($resul as $row) { $devise->charger($row->id); $prix = $prix2 = $convert = 0; if (!empty($prod->id)) { $prix = $prod->prix * $devise->taux; $prix2 = $prod->prix2 * $devise->taux; } if (!empty($somme)) { $convert = $somme * $devise->taux; } $total = $_SESSION['navig']->panier->total(1) * $devise->taux; $temp = str_replace("#ID", $devise->id, $texte); $temp = str_replace("#PRIX2", formatter_somme($prix2), $temp); $temp = str_replace("#PRIX", formatter_somme($prix), $temp); $temp = str_replace("#TOTAL", formatter_somme($total), $temp); $temp = str_replace("#CONVERT", formatter_somme($convert), $temp); $temp = str_replace("#NOM", $devise->nom, $temp); $temp = str_replace("#CODE", $devise->code, $temp); $temp = str_replace("#TAUX", $devise->taux, $temp); $temp = str_replace("#HTMLSYMBOLE", htmlentities($devise->symbole, ENT_COMPAT, 'UTF-8', false), $temp); $temp = str_replace("#SYMBOLE", $devise->symbole, $temp); $temp = str_replace("#DEFAUT", $devise->defaut, $temp); $temp = str_replace("#COURANTE", $devise->id == ActionsDevises::instance()->get_id_devise_courante() ? "1" : "0", $temp); $temp = str_replace('#URL', $url . 'devise=' . $devise->id, $temp); $res .= $temp; } } return $res; }
require_once "title.php"; require_once "../fonctions/divers.php"; if (!isset($action)) { $action = ""; } if (!isset($statutch)) { $statutch = ""; } ?> <?php $commande = new Commande(); $commande->charger_ref($ref); $modules = new Modules(); $modules->charger_id($commande->paiement); $devise = new Devise(); $devise->charger($commande->devise); if ($statutch) { $commande->setStatutAndSave($statutch); } if (isset($colis) && $colis != "") { $commande->colis = $colis; $commande->maj(); ActionsModules::instance()->appel_module("statut", $commande, $commande->statut); } ?> </head> <body>
function lister_commandes($critere, $order, $debut, $nbres, $search = '') { $commande = new Commande(); $i = 0; $query = "select * from {$commande->table} where 1 {$search} order by {$critere} {$order} limit {$debut},{$nbres}"; $resul = $commande->query($query); while ($resul && ($row = $commande->fetch_object($resul, 'Commande'))) { $client = new Client(); $client->charger_id($row->client); $statutdesc = new Statutdesc(); $statutdesc->charger($row->statut); $devise = new Devise(); $devise->charger($row->devise); $total = formatter_somme($row->total(true, true)); $date = strftime("%d/%m/%y %H:%M:%S", strtotime($row->date)); $fond = "ligne_" . ($i++ % 2 ? "claire" : "fonce") . "_rub"; ?> <ul class="<?php echo $fond; ?> "> <li style="width:142px;"><?php echo $row->ref; ?> </li> <li style="width:104px;"><?php echo $date; ?> </li> <li style="width:200px;"><?php echo $client->entreprise; ?> </li> <li style="width:200px;"><a href="client_visualiser.php?ref=<?php echo $client->ref; ?> "><?php echo $client->nom . " " . $client->prenom; ?> </a></li> <li style="width:59px;"><?php echo $total; ?> <?php echo $devise->symbole; ?> </li> <li style="width:70px;"><?php echo $statutdesc->titre; ?> </li> <li style="width:40px;"><a href="commande_details.php?ref=<?php echo $row->ref; ?> ">éditer</a></li> <?php if ($row->statut != Commande::ANNULE) { ?> <li style="width:35px; text-align:center;"><a href="#" onclick="supprimer('<?php echo $row->id; ?> '); return false;"><img src="gfx/supprimer.gif" width="9" height="9" border="0" /></a></li> <?php } ?> </ul> <?php } }
$objPHPExcel->getActiveSheet()->setCellValue('F8', $sessionUser->getLogin()); $objPHPExcel->getActiveSheet()->setCellValue('J8', $CloneDevise->getName()); $datePremierFrais; $dateDernierFrais; $totalAvance = 0; $totalCase = 0; $totalTTC = 0; $baseRow = 16; //On boucle pour afficher les informations de chaques frais de la note dans le tableau excel foreach ($allFraisFromThisNote as $r => $fraisFromNote) { $row = $baseRow + $r; $CategorieName = CategorieFrais::getCategorieById($bdd, $fraisFromNote['categorie_id']); $objPHPExcel->getActiveSheet()->insertNewRowBefore($row, 1); //Affiche dans la bonne devise $deviseFrais = Devise::getDeviseById($bdd, $fraisFromNote['devise_id']); $montantDeviseUser = Devise::getValueOfChangedDevise($fraisFromNote['montant'], $deviseFrais->getTaux(), $CloneDevise->getTaux()); //Verifie si on a une avance if ($fraisFromNote['categorie_id'] == 4) { $totalAvance += $montantDeviseUser; $tva = $montantDeviseUser; $totalTTC -= $montantDeviseUser; } else { $tva = $montantDeviseUser * 1.2; $totalTTC += $tva; } $objPHPExcel->getActiveSheet()->setCellValue('A' . $row, $fraisFromNote['id'])->setCellValue('B' . $row, $fraisFromNote['date'])->setCellValue('C' . $row, $fraisFromNote['description'])->setCellValue('E' . $row, $montantDeviseUser)->setCellValue('F' . $row, $tva)->setCellValue('H' . $row, $CategorieName->getName()); $dateFrais = $fraisFromNote['date']; //On récupère la première et la dernière date if ($row == 16) { $datePremierFrais = $fraisFromNote['date']; $dateDernierFrais = $fraisFromNote['date'];
public function getSearchList($searchTerm, $clientFoundList) { $searchTerm = $this->escape_string(trim($searchTerm)); $return = array(); if ($searchTerm === '' && count($clientFoundList) == 0) { return $return; } $qOrders = "SELECT * FROM " . self::TABLE . "\n WHERE ref like '%{$searchTerm}%'\n OR facture like '%{$searchTerm}%'\n OR transaction like '%{$searchTerm}%'\n " . (count($clientFoundList) > 0 ? " OR client IN (" . implode(',', $clientFoundList) . ")" : '') . "\n " . (strtotime($searchTerm) ? " OR date LIKE '" . date('Y-m-d', strtotime($searchTerm)) . "%'" : '') . "\n LIMIT 100"; $rOrders = $this->query($qOrders); while ($rOrders && ($theOrder = $this->fetch_object($rOrders, 'Commande'))) { $thisOrderArray = array(); $client = new Client(); $client->charger_id($theOrder->client); $statutdesc = new Statutdesc(); $statutdesc->charger($theOrder->statut); $devise = new Devise(); $devise->charger($theOrder->devise); $total = formatter_somme($theOrder->total(true, true)); $date = strftime("%d/%m/%y %H:%M:%S", strtotime($theOrder->date)); $thisOrderArray['ref'] = $theOrder->ref; $thisOrderArray['transaction'] = $theOrder->transaction; $thisOrderArray['facture'] = $theOrder->facture; $thisOrderArray['date'] = $date; $thisOrderArray['client'] = array("entreprise" => $client->entreprise, "ref" => $client->ref, "nom" => $client->nom, "prenom" => $client->prenom); $thisOrderArray['total'] = $total; $thisOrderArray['devise'] = $devise->symbole; $thisOrderArray['titre'] = $statutdesc->titre; $thisOrderArray['statut'] = $theOrder->statut; $thisOrderArray['id'] = $theOrder->id; $return[] = $thisOrderArray; } return $return; }
<div class="admin-stat"> <h1>Statistiques du site (en <?php echo Devise::getDeviseById($bdd, $sessionUser->getDevise())->getSigne(); ?>)</h1> <div class="chart"> <h3>Couts par categorie : </h3> <canvas id="categorieChart" width="500" height="500"></canvas> </div> <div class="chart"> <h3>Couts des Frais par mois :</h3> <canvas id="fraisChart" width="500" height="500"></canvas> </div> <div class="chart"> <h3>Couts des 10 premiers utilisateurs :</h3> <canvas id="userChart" width="500" height="500"></canvas> </div> </div>