コード例 #1
0
ファイル: boucles.php プロジェクト: anti-conformiste/thelia1
function bouclePage($texte, $args)
{
    global $page, $id_rubrique, $id_dossier;
    // récupération des arguments
    $num = lireTag($args, "num", "int");
    $courante = lireTag($args, "courante", "int");
    $pagecourante = lireTag($args, "pagecourante", "int");
    $typeaff = lireTag($args, "typeaff", "int");
    $max = lireTag($args, "max", "int");
    $affmin = lireTag($args, "affmin", "int");
    $avance = lireTag($args, "avance", "string");
    $type_page = lireTag($args, "type_page", "int");
    /** PARAMÈTRES DÉPRÉCIÉS, A NE PLUS UTILISER */
    $deb = lireTag($args, "deb", "int");
    $totbloc = lireTag($args, "totbloc", "int");
    /** FIN PARAMÈTRES DÉPRÉCIÉS */
    $i = "";
    if ($page <= 0) {
        $page = 1;
    }
    $bpage = $page;
    $res = "";
    $cnx = new Cnx();
    if (!$type_page) {
        $query = boucleProduit($texte, str_replace("num", "null", $args), 1);
    } else {
        $query = boucleContenu($texte, str_replace("num", "null", $args), 1);
    }
    if ($query != "") {
        $pos = strpos($query, "limit");
        if ($pos > 0) {
            $query = substr($query, 0, $pos);
        }
        $resul = $cnx->query($query);
        $nbres = $cnx->num_rows($resul);
    } else {
        $nbres = 0;
    }
    $page = $bpage;
    $nbpage = $num ? ceil($nbres / $num) : 0;
    if ($page + 1 > $nbpage) {
        $pagesuiv = $page;
    } else {
        $pagesuiv = $page + 1;
    }
    if ($page - 1 <= 0) {
        $pageprec = 1;
    } else {
        $pageprec = $page - 1;
    }
    if ($nbpage < $affmin) {
        return;
    }
    if ($nbpage == 1) {
        return;
    }
    if ($typeaff == 1) {
        if (!$max) {
            $max = $nbpage + 1;
        }
        if ($page && $max && $page > $max) {
            $i = ceil($page / $max) * $max - $max + 1;
        }
        if ($i == 0) {
            $i = 1;
        }
        $fin = $i + $max;
        for (; $i < $nbpage + 1 && $i < $fin; $i++) {
            $temp = str_replace("#PAGE_NUM", "{$i}", $texte);
            $temp = str_replace("#PAGE_SUIV", "{$pagesuiv}", $temp);
            $temp = str_replace("#PAGE_PREC", "{$pageprec}", $temp);
            $temp = str_replace("#RUBRIQUE", "{$id_rubrique}", $temp);
            $temp = str_replace("#DOSSIER", "{$id_dossier}", $temp);
            if ($pagecourante && $pagecourante == $i) {
                if ($courante == "1" && $page == $i) {
                    $res .= $temp;
                } else {
                    if ($courante == "0" && $page != $i) {
                        $res .= $temp;
                    } else {
                        if ($courante == "") {
                            $res .= $temp;
                        }
                    }
                }
            } else {
                if (!$pagecourante) {
                    $res .= $temp;
                }
            }
        }
    } else {
        if ($typeaff == "0" && ($avance == "precedente" && $pageprec != $page)) {
            $temp = str_replace("#PAGE_NUM", "{$page}", $texte);
            $temp = str_replace("#PAGE_PREC", "{$pageprec}", $temp);
            $temp = str_replace("#RUBRIQUE", "{$id_rubrique}", $temp);
            $temp = str_replace("#DOSSIER", "{$id_dossier}", $temp);
            $res .= $temp;
        } else {
            if ($typeaff == "0" && ($avance == "suivante" && $pagesuiv != $page)) {
                $temp = str_replace("#PAGE_NUM", "{$page}", $texte);
                $temp = str_replace("#PAGE_SUIV", "{$pagesuiv}", $temp);
                $temp = str_replace("#RUBRIQUE", "{$id_rubrique}", $temp);
                $temp = str_replace("#DOSSIER", "{$id_dossier}", $temp);
                $res .= $temp;
            } else {
                if ($typeaff == "0" && $avance == "") {
                    $temp = str_replace("#PAGE_NUM", "{$page}", $texte);
                    $temp = str_replace("#PAGE_SUIV", "{$pagesuiv}", $temp);
                    $temp = str_replace("#PAGE_PREC", "{$pageprec}", $temp);
                    $temp = str_replace("#RUBRIQUE", "{$id_rubrique}", $temp);
                    $temp = str_replace("#DOSSIER", "{$id_dossier}", $temp);
                    $res .= $temp;
                } else {
                    if ($typeaff == "2") {
                        /** DEPREACTED le typeaff 2 n'est plus utilisé, concervé pour rétrocompatibilité */
                        if (!$deb) {
                            $deb = 0;
                        }
                        if ($page) {
                            $_SESSION['navig']->page = $page;
                        }
                        if (!$page || $page == 1) {
                            $page = 0;
                        }
                        if (!$totbloc) {
                            $totbloc = 1;
                        }
                        if ($page) {
                            $deb = ($page - 1) * $totbloc * $num + $deb;
                        }
                        $fin = $deb + $num;
                        $query = str_replace("*", "count(*) as max", $query);
                        $resul = $cnx->query($query);
                        $max = $cnx->get_result($resul, 0, "max");
                        if ($fin > $max) {
                            $fin = $max;
                        }
                        $temp = str_replace("#DEBUT", $deb, $texte);
                        $temp = str_replace("#FIN", $fin, $temp);
                        $temp = str_replace("#MAX", $max, $temp);
                        $res .= $temp;
                        /** END DEPRECATED */
                    }
                }
            }
        }
    }
    return $res;
}
コード例 #2
0
ファイル: accueil.php プロジェクト: anti-conformiste/thelia1
$nbproduitenligne = get_result("select count(*) as nb from " . Produit::TABLE . " where ligne=1");
$nbproduithorsligne = $nbproduit - $nbproduitenligne;
$port = get_result("select sum(port) as totport from " . Commande::TABLE . " where {$cond_commande_paye}");
$ca = round(get_result("SELECT sum(quantite*prixu) as ca FROM " . Venteprod::TABLE . " where commande in ({$in_commande_paye})"), 2);
$ca += get_result("SELECT sum(port) as ca FROM " . Commande::TABLE . " where id in ({$in_commande_paye})");
$ca -= get_result("SELECT sum(remise) as ca FROM " . Commande::TABLE . " where id in ({$in_commande_paye})");
$casf = $ca - $port;
$nbCommande = get_result("SELECT count(*) as nbCommande FROM " . Commande::TABLE . " where {$cond_commande_paye}");
if ($nbCommande > 0) {
    $panierMoyen = round($ca / $nbCommande, 2);
} else {
    $panierMoyen = 0;
}
// La liste des commandes du mois courant
$query = "select id from " . Commande::TABLE . " where datefact like '" . date("Y") . "-" . date("m") . "-%%' and {$cond_commande_paye}";
$resul = $cnx->query($query);
$list = array();
while ($resul && ($row = $cnx->fetch_object($resul))) {
    $list[] = $row->id;
}
if (count($list) == 0) {
    $list = '0';
} else {
    $list = implode(',', $list);
}
$camois = round(get_result("SELECT sum(quantite*prixu) as camois FROM " . Venteprod::TABLE . " where commande in ({$list})"), 2);
$camois += get_result("SELECT sum(port) as port FROM " . Commande::TABLE . " where id in ({$list})");
$camois -= get_result("SELECT sum(remise) as remise FROM " . Commande::TABLE . " where id in ({$list})");
$nbcmdannulee = get_result("select count(*) as nbcmdannulee from " . Commande::TABLE . " where statut = " . Commande::ANNULE);
$nbrubrique = get_result("select count(id) as nbRubrique from " . Rubrique::TABLE);
// Dernière version