• jeanmichel83

    (@jeanmichel83)


    Bonjour, ci-dessous le fichier

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
    <html>
    <head>
    <!--<link rel="stylesheet" type="text/css" href="../style.css">-->
    
    <title>Preparation de commandes</title>
    
    </head>
    <body>
    
    <?php
    //include($_SERVER["DOCUMENT_ROOT"]."_connexion.php");
    include($_SERVER["DOCUMENT_ROOT"]."./wp-load.php");
    include($_SERVER["DOCUMENT_ROOT"]."./wp-includes/wp-db.php");
    ?>
    
    <table width="100%" align="center" bgcolor="#FFFFFF">
                            <tr> 
                              <td height="18" valign="middle"> 
                                <div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
                                  </font><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">| 
                                 <a href="ed_ent_date_tous.php">Retour</a></font> 
                                </div>
                                
                            </tr>
    </table>
    <form  id="form" name="form" action="" method="POST" >
    <table width="100%" align="center" bgcolor="#FFFFFF">
    
     <?php
    echo "----------------------";
    
    // on récupére les dates et le cbarre_tech
    $datedeb=$_POST['C1'];
    list($jour,$mois,$annee) = explode("/",$datedeb);
    $v_datedeb= $annee."-".$mois."-".$jour;
    $datefin=$_POST['C2'];
    list($jour,$mois,$annee) = explode("/",$datefin);
    $v_datefin= $annee."-".$mois."-".$jour;
    
    // on créer les dates pour le select date début et date fin avec les heures minutes et secondes
    $dated = new DateTime($v_datedeb);
    $min = $dated->format('Y-m-d 00:00:00');
    $datef = new DateTime($v_datefin);
    $max = $datef->format('Y-m-d 23:59:59');
    // on interroge post_meta 
    global $wpdb;
    $wpdb->show_errors(); 
    $wpdb = new wpdb(‘’,’’,’’,’’);
    
    $sql1 = $wpdb->get_results("SELECT DISTINCT(p.id),p.post_date FROM $wpdb->posts  p
    left JOIN $wpdb->postmeta  m ON m.post_id = p.id
    where p.post_type='wpshop_shop_order'
    and p.post_date > '$min' 
    and p.post_date < '$max'
    ");
    
    foreach($sql1 as $result){
    $post_id=$result->id; 
    $edit_last = get_post_meta( $post_id,"_order_postmeta",true);
    $num_cde = $edit_last['order_key'];
    $date_cde = $edit_last['order_date'];
    $cle = (array_keys($edit_last['order_items']));
    for($i = 0;$i <= count($cle); $i++)
    {
    $cle1 = $cle[$i] ;
    $prixu = $edit_last['order_items'][$cle1][item_pu_ttc];
    $nomprod = $edit_last['order_items'][$cle1][item_name];
    $qteprod = $edit_last['order_items'][$cle1][item_qty];
    $wpdb->insert('mod42_transf3',array('id_cl3'=>$post_id,'prod_cl'=>$nomprod,'qte_cl'=>$qteprod,'prix_cl'=>$prixu),
    array('%s','%s','%s','%s'));
    $wpdb->insert('mod42_transf4',array('id_cl4'=>$post_id,'qte_cl4'=>$qteprod,'prix_tot'=>$prixu*$qteprod),
    array('%s','%s','%s'));
    }
    
    $edit_last1 = get_post_meta( $post_id,"_order_info",true);
    $cle2 = (array_keys($edit_last1['billing']));
    for($ii = 1;$ii <= count($cle2); $ii++)
    {
    $cle3 = $cle2[$ii] ;
    $nom =  $edit_last1[billing][$cle3][address_last_name];
    $pnom = $edit_last1[billing][$cle3][address_first_name];
    $city = $edit_last1[billing][$cle3][city];
    $wpdb->insert('mod42_transf2',array('id_cl2'=>$post_id,'nom_cl'=>$nom,'pnom_cl'=>$pnom,'ville_cl'=>$city),array('%s','%s','%s','%s'));
    }
    
    }
    echo "passe";
    if ($min <> 0) {
    $sql2 = $wpdb->get_results("SELECT id_cl3,nom_cl,pnom_cl,ville_cl,prod_cl,qte_cl,prix_cl
    from mod42_transf2, mod42_transf3
    where mod42_transf2.id_cl2 = mod42_transf3.id_cl3
    order by nom_cl");
    echo "<a>Les Commandes entre le </a>";
    echo $datedeb;
    echo "<a> et le </a>";
    echo $datefin;
    echo "<table class=\"texte\" width=\"100%\" border=\"0\" bordercolor=\"#000066\" cellspacing=\"0\" align=\"center\" >";
    echo "<tr>";
    echo "<td align=\"left\" bgcolor=\"#DBE8E8\">Prenom - Nom</td>";
    echo "<td align=\"left\" bgcolor=\"#DBE8E8\">Ville</td>";
    echo "<td align=\"left\" bgcolor=\"#DBE8E8\">Produits</td>";
    echo "<td align=\"left\" bgcolor=\"#DBE8E8\">Qte</td>";
    echo "<td align=\"left\" bgcolor=\"#DBE8E8\">Prix Unit.</td>";
    echo "<td align=\"left\" bgcolor=\"#DBE8E8\">Total Com.</td>";
    $idcl = "";
    foreach($sql2 as $result1){
    echo "<tr>";
    if ($result1->id_cl3 <>  $idcl ) {
        echo "<td align=\"left\">$result1->pnom_cl - $result1->nom_cl</td>";
        echo "<td align=\"left\">$result1->ville_cl</td>";
        echo "<td align=\"left\">$result1->prod_cl</td>";
        echo "<td align=\"left\">$result1->qte_cl</td>";
        echo "<td align=\"left\">$result1->prix_cl</td>";
         $sql3 = $wpdb->get_results("SELECT id_cl4,SUM(prix_tot) as prixtot
        from mod42_transf4
         where mod42_transf4.id_cl4 = $result1->id_cl3
         group by id_cl4");
        foreach($sql3 as $result2){
          $conv = number_format($result2->prixtot,2,',','');
          echo "<td align=\"left\">$conv</td>";
         }
    }else{
          echo "<td align=\"left\"></td>";
          echo "<td align=\"left\"></td>";
          echo "<td align=\"left\">$result1->prod_cl</td>";
          echo "<td align=\"left\">$result1->qte_cl</td>";
          echo "<td align=\"left\">$result1->prix_cl</td>";
          echo "<td align=\"left\">  </td>";
        }
    
        $idcl = $result1->id_cl3;
    }
    
    }
    echo "</table>";
    $wpdb->print_error();
    ?>
    
    </table>
    
    </form>
    </head>
    
    </body>
    </html>
    

    j ai bien récuperé mes 2 variables $min et $max
    mais je dois avoir un pb de connexion à la base cependant je n ai aucune erreur la page résultat s’affiche mais vide ?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    I hope you can make sense of a response in English. I do not see any obvious errors in your code. Because of your custom data, we cannot test your code ourselves. You will need to debug this yourself.

    Check the values of the variables used to ensure they have the values they should. This is failing to happen somewhere. Check values by inserting lines similar to print_r( $variable ); at strategic places. It can be tedious checking every variable. If you are methodical, you will eventually find the problem.

Viewing 1 replies (of 1 total)
  • The topic ‘programmation php connexion a une base wordpress’ is closed to new replies.