0byt3m1n1
Path:
/
home
/
k
/
a
/
s
/
kassiope
/
www
/
administrer
/
[
Home
]
File: exportcompta.php
<?php include("../configuration.inc.php"); necessite_identification(); necessite_priv("admin"); $f = ''; $sup = ''; $csv = ''; $cpt=0; $sql = "select * from gaia_commandes c, gaia_utilisateurs u where c.id_utilisateur = u.id_utilisateur ".$sup." and (statut = '8' or statut = '3' or statut = '5' or statut = '10') and o_timestamp like '".date('Y')."-%' order by o_timestamp"; $sql = "select * from gaia_commandes c, gaia_utilisateurs u where c.id_utilisateur = u.id_utilisateur ".$sup." and (statut = '8' or statut = '3' or statut = '5' or statut = '10') and a_timestamp like '".date('Y')."-%' order by a_timestamp"; $reccom = mysql_query_override ($sql); $total_ttc = $total_transport = $tot_tva = 0; while ($com = mysql_fetch_array_override($reccom)) { $societe = html_entity_decode((stripslashes($com['societe']))); $nom = html_entity_decode((stripslashes($com['prenom_bill'].' '.$com['nom_bill']))); $recprod = mysql_query_override ("select sum(total_prix) as totprix, sum(total_prix_ht) as totprix_ht from gaia_commandes_articles where commande_id = '".$com['id']."'"); $prod = mysql_fetch_array_override($recprod); $remise_tva = $com['remise_proforma_calcul'] - $com['remise_proforma_calcul_ht']; $totprix = $prod['totprix']; $totprix_ht = $prod['totprix_ht']; $total_tva = $com['total_tva']; if($com['remise_code']>0) { $totprix = $com['total_produit']; //$total_tva = $com['total_tva']; $totprix_ht = $totprix - $total_tva; } if($com['remise_proforma_calcul']>0) { $totprix = $com['total_produit_avant_promo'] - $com['remise_proforma_calcul']; $totprix_ht = $com['total_produit_avant_promo_ht'] - $com['remise_proforma_calcul_ht']; //$total_tva = $com['total_tva'] - $remise_tva; //$totprix_ht = $totprix - $total_tva; } /* if(!empty($com['code_promo'])) { $recpromo = mysql_query_override("select * from gaia_codes_promos where nom = '".$com['code_promo']."'"); $res = mysql_fetch_array_override($recpromo); $totprix = $totprix - $totprix*$rec['remise']/100; $totprix_ht = $totprix_ht - $totprix_ht*$rec['remise']/100; $total_tva = $totprix - $totprix_ht; } */ $csv.= utf8_decode($com['a_timestamp'].';'.$com['id'].';'.$com['numero'].';'.$societe.';'.$nom.';'.(($com['priv']=='reve')?'revendeur':'client').';'.number_format($totprix,2,',','').';'.number_format($totprix_ht,2,',','').';'.number_format($com['cout_transport_ht'],2,',','').';'.number_format($total_tva,2,',','').';'.number_format($totprix+$com['cout_transport'],2,',','').';'.html_entity_decode(($com['paiement'])))."\n"; $total_ttc += $totprix_ht; $total_transport += $com['cout_transport_ht']; $tot_tva += $total_tva; //$csv.= utf8_decode($com['a_timestamp'].';'.$com['numero'].';'.(($_GET['cli']==1)?$societe:$nom).';'.number_format($totprix+$com['cout_transport'],2,',','').';;'.html_entity_decode(($com['paiement'])))."\n"; //mysql_query_override ("update gaia_commandes set compta='1' where id = '".$com['id']."' "); } $precsv = ''; $precsv .= date('d/m/Y').';;TOTAL VENTES HT A RECALCULER;;'.number_format($total_ttc,2,',','')."\n"; $precsv .= date('d/m/Y').';;TOTAL TVA;;'.number_format($tot_tva,2,',','')."\n"; $precsv .= date('d/m/Y').';;TOTAL TRANSPORT HT;;'.number_format($total_transport,2,',','')."\n"; $precsv .= 'Date;Num commande;Num facture;Societe;Client;Type;Total produits TTC;Total produits HT;Transport HT;Total TVA;Total TTC;Paiement'."\n"; header("Content-type: application/vnd.ms-excel"); header("Content-disposition: attachment; filename=\"exportcompta".$f.".csv\""); print($precsv.$csv); exit; ?>