1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
|
<script>
function visibilite(thingId) {
var targetElement;
targetElement = document.getElementById("div_section_"+thingId);
if (targetElement.style.display == "none") {
targetElement.style.display="";
document.getElementById("btn_section_"+thingId).src="../images/admin/piece_close.png";
}
else {
targetElement.style.display="none";
document.getElementById("btn_section_"+thingId).src="../images/admin/piece_open.png";
}
}
</script>
<?php
session_start();
$numfac = $_SESSION['toto']->checkbox;
if ( $log == "ok" ) {
$cnx = odbc_connect( $base_bdd_catalogue, $login_bdd_catalogue, $pwd_bdd_catalogue);
if($cnx) {
$code_client = "";
$mois_en_cours = date("Ym");
$req_ciel= odbc_exec( $cnx, "SELECT N° FROM Clients WHERE Code like '".$_SESSION['compte_CodeCiel']."' ");
if (odbc_fetch_row($req_ciel)) {
$client_ciel_N° = odbc_result($req_ciel,'N°');
}
if ( $client_ciel_N° != "" ) {
$array_piece_mois = array();
$array_index_mois = 0;
$array_piece_old = array();
$array_index_old = 0;
$facture_client= odbc_exec( $cnx, "SELECT * FROM Pièces WHERE N°Client LIKE '".$client_ciel_N°."' AND ResteAPayer>0 ORDER BY N° DESC");
while(odbc_fetch_row($facture_client)) {
$piece_num = odbc_result($facture_client,'N°Pièce');
$piece_type = odbc_result($facture_client,'Type');
$souche_filtre = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
$piece_souche = str_replace($souche_filtre,'',$piece_num);
$piece_ResteAPayer = odbc_result($facture_client,'ResteAPayer');
$piece_Date = odbc_result($facture_client,'Date');
$piece_mois = substr($piece_Date,0,4).substr($piece_Date,5,2);
// trie des pièces
if ( $piece_type<>$ciel_pièce_type && $piece_ResteAPayer<>0 || ( $piece_type==$ciel_pièce_type && $piece_mois<=$mois_en_cours ) ) {
$array_index_mois += 1;
$array_piece_mois[$array_index_mois]['id'] = odbc_result($facture_client,'N°');
$array_piece_mois[$array_index_mois]['num'] = $piece_num;
$array_piece_mois[$array_index_mois]['date'] = $piece_Date;
$array_piece_mois[$array_index_mois]['ttc'] = round(odbc_result($facture_client,'NetTTC'),2);
$array_piece_mois[$array_index_mois]['ht'] = round(odbc_result($facture_client,'NetHT'),2);
$array_piece_mois[$array_index_mois]['ResteAPayer'] = $piece_ResteAPayer;
$array_piece_mois[$array_index_mois]['N°CmdWeb'] = odbc_result($facture_client,'N°CmdWeb');
$array_piece_mois[$array_index_mois]['Type'] = odbc_result($facture_client,'Type');
$array_piece_mois[$array_index_mois]['vendeur'] = odbc_result($facture_client,'N°Vendeur');
$array_piece_mois[$array_index_mois]['Référence'] = odbc_result($facture_client,'Référence');
}
}
// affiche les pièces factures/devis en cours
echo "<center><h3> En cours : </h3></center>";
echo "<center><table border='0' bgcolor='#3c3c3c' width='725px'>
<tr>
<td width='20px'></td>
<td width='80px' align='center'><b> N° </b></td>
<td width='100px' align='center'><b> Ref client </b></td>
<td width='115px' align='center'><b> Date </b></td>
<td width='100px' align='center'><b> Statut </b></td>
<td width='100px' align='center'><b> HT </b></td>
<td width='100px' align='center'><b> TTC </b></td>
<td width='100px' align='center'><b> SOLDER </b></td>
<td width='20px'></td>
</tr>
</table></center>";
foreach ($array_piece_mois as $piece_item) {
$piece_color = "#bd3b3b";
$piece_info = "Inconnu";
$impression_type = "Imprimer";
$extra = "";
if ( $piece_item['vendeur']==10 ) {
if ( $piece_item['Type']==0 && $piece_item['ResteAPayer']<>0 ) { $piece_color = "#bd3b3b"; $piece_info = "Facture non soldée"; $impression_type = "Imprimer la facture"; }
else if ( $piece_item['Type']==0 ) { $piece_color = "#27b123"; $piece_info = "Facture soldée"; $impression_type = "Imprimer la facture"; }
else if ( $piece_item['Type']==1 && $piece_item['ResteAPayer']<>0 ) { $piece_color = "#e5ab1f"; $piece_info = "Commande en attente"; $impression_type = "Imprimer la commande"; }
else if ( $piece_item['Type']==1 ) { $piece_color = "#27b123"; $piece_info = "Cde terminée, soldée"; $impression_type = "Imprimer la facture"; }
else if ( $piece_item['Type']==$ciel_pièce_type && $piece_item['ResteAPayer']<>0 ) { $piece_color = "#bd3b3b"; $piece_info = "non soldé"; $impression_type = "Imprimer la facture"; }
else if ( $piece_item['Type']==$ciel_pièce_type ) { $piece_color = "#27b123"; $piece_info = "soldé"; $impression_type = "Imprimer la facture"; }
}
else {
if ( $piece_item['Type']==1 ) {
$piece_color = "#0271b8";
$piece_info = "Devis en cours";
$impression_type = "Imprimer le devis";
$extra = "<span style='float:right;'>
<a title='Valider le devis' href='index.php?page=./pages_compte/compte_accueil&souspage=./pages_client/compte_client_ciel&num=".$piece_item['num']."&piece=".$piece_item['id']."&action=valide_devis'><img src='./images/compte/logo/btn_devis_valider.png' /></a>
<a title='Supprimer le devis' href='index.php?page=./pages_compte/compte_accueil&souspage=./pages_client/compte_client_ciel&num=".$piece_item['num']."&piece=".$piece_item['id']."&action=supprime_devis'><img src='./images/compte/logo/btn_devis_supprimer.png' /></a>
</span>";
}
else if ( $piece_item['Type']==0 && $piece_item['ResteAPayer']<>0 ) { $piece_color = "#bd3b3b"; $piece_info = "Facture à payer"; $impression_type = "Imprimer la facture";}
else if ( $piece_item['Type']==0 ) { $piece_color = "#27b123"; $piece_info = "Facture soldée"; $impression_type = "Imprimer la facture"; }
}
echo "<center><table border='0' bgcolor='#4c4c4c' width='725px' style='margin-top:1px;'>
<tr>
<td width='20px'>"; ?><a href="#" title="Afficher/Masquer les détails"><img id="<?php echo "btn_section_".$piece_item['id']; ?>" src="../images/admin/conteneur_open.png" onclick="visibilite('<?php echo $piece_item['id']; ?>');"/></a><?php echo "</td>
<td width='80px' align='center'><b>".$piece_item['num']."</b></td>
<td width='100px' align='center'><b>".$piece_item['N°CmdWeb']."</b></td>
<td width='115px' align='center'><b>".substr($piece_item['date'],8,2)."-".substr($piece_item['date'],5,2)."-".substr($piece_item['date'],0,4)."</b></td>
<td width='100px' align='center'><b style='color:".$piece_color.";'>".$piece_info." ".$extra."</b></td>
<td width='100px' align='center'><b style='color:".$piece_color.";'>".number_format($piece_item['ht'],2)."   </b></td>
<td width='100px' align='center'><b style='color:".$piece_color.";'>".number_format($piece_item['ttc'],2)."   </b></td>
<td width='100px' align='center'>
<form method='post' >
<input type='checkbox' name='ttc[".$piece_item['num']."]' value='".number_format($piece_item['ttc'],2)."'>
<td width='20px'><a href='./pages_client/piece_imprime.php?client=".$_SESSION['compte_CodeCiel']."&piece=".$piece_item['id']."&piece_nom=".$piece_item['num']."' target='_BLANK' title='".$impression_type."'><img src='./images/compte/logo/adobe.png'/></a></td>
</table></center>
<div id='div_section_".$piece_item['id']."' style='display:none;font-size:8pt;'><center><table border='0' bgcolor='#5c5c5c' width='725px'>";
//$total = 0;
//foreach($_POST['ttc'] as $key => $value) {
//$total += $value;
$total = 0;
foreach ($_POST['ttc'] as $num_fa => $montant)
{
$total += $montant;
echo 'Facture ', $num_fa, ' : ', $montant, ' - Total : ', $total, "\n";
}
//$tableau[] = $key;
//$a = $tableau[0];
//$b = $tableau[1];
//$c = $tableau[2];
//$numfac = $a." ".$b." ".$c ;
//$numfac2=substr($b, strpos ($b,'(') , 6);
//$numfac2=str_replace(")", "", $numfac2);
//$numfac3=substr($c, strpos ($c,'(') , 12);
//$numfac3=str_replace(")", "", $numfac3);
//}//
$facture_article= odbc_exec( $cnx, "SELECT * FROM PiècesLignes WHERE N°Pièce=".$piece_item['id']." ORDER BY N° ASC");
while(odbc_fetch_row($facture_article)) {
if ( odbc_result($facture_article,'Type') == 0 ) {
// article
$req_article= odbc_exec( $cnx, "SELECT Code FROM Articles WHERE N°=".odbc_result($facture_article,'N°Article')." ");
if ( odbc_fetch_row($req_article) ) {
$ref_article = odbc_result($req_article,'Code');
}
echo "<tr>
<td width='120px' align='left'>".$ref_article."</td>
<td width='25px'>".number_format(odbc_result($facture_article,'Qté'),0)."</td>
<td width='' align='left'>".odbc_result($facture_article,'Libellé')."</td>
<td width='80px' align='right'>".number_format(odbc_result($facture_article,'NetHT'),2)."   </td>
<td width='80px' align='right'>".number_format(odbc_result($facture_article,'NetTTC'),2)."   </td>
<td width='20px'> </td>
</tr>";
}
else if ( odbc_result($facture_article,'Type') == 4 ) {
// commentaire
echo "<tr>
<td width='120px' align='left'> </td>
<td width='25px'> </td>
<td width='' align='left'>".odbc_result($facture_article,'Libellé')."</td>
<td width='80px' align='right'> </td>
<td width='80px' align='right'> </td>
<td width='20px'> </td>
</tr>";
}
}
echo "</table></center></div>";
}
// DEBUT résultat du checkbox
// affiche bouton valider
echo" <input style='margin-left: 583px' type='submit' value='Valider / Annuler'>
</form> ";
// affichage tableau réglement
echo "
<div id='cadre_paiement_en_ligne'>
Vous avez séléctionner la/les facture(s) suivantes.
<input style='width:200px ; text-align:center; background-color: #c0c0c0;' name='ttc' value='".$num_fa."' >
<div id='txt_montantreglement'>Montant total de votre règlement : </div>
<div id='checkbox_paiementenligne'>
<input type='text' style='width:60px ;text-align:center' name='ttc' value='".number_format($total,2)."' >
</div>
<div id='txt_paiement_en_ligne'>Paiement en ligne</div>
<div id='img_paiement_en_ligne'><a href='./payment/call_request.php'><img src='./images/paiement_en_ligne/logo_CB.png'></div></a>
</div>";
// FIN résultat du checkbox
}
echo "<br/>";
}
}
else echo "<br/><center><p class='erreur'><img class='logo' src='./images/warning.png' alt=''/> Votre session est invalide ! </p></center>";
// DEBUT génération "id transaction" pour paiement en ligne
$sans_lettre = substr($numfac,1);
$id_transaction = $sans_lettre;
// FIN génération "id transaction" pour paiement en ligne
// DEBUT envois des variables vers "call_paiement
$_SESSION['id_transaction'] = $id_transaction;
$_SESSION['total'] = $total;
// FIN envois des variables vers "call_paiement
?> |
Partager