Linux vps-61133.fhnet.fr 4.9.0-19-amd64 #1 SMP Debian 4.9.320-2 (2022-06-30) x86_64
Apache/2.4.25 (Debian)
Server IP : 93.113.207.21 & Your IP : 216.73.216.35
Domains :
Cant Read [ /etc/named.conf ]
User : www-data
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
var /
www /
html /
asiafood.bdcloud.fr /
Delete
Unzip
Name
Size
Permission
Date
Action
accountancy
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
adherents
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
admin
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
api
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
asset
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
asterisk
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
barcode
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
blockedlog
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
bom
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
bookmarks
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
build
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
cashdesk
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
categories
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
collab
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
comm
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
commande
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
compta
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
conf
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
contact
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
contrat
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
core
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
cron
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
custom
[ DIR ]
drwxrwxrwx
2025-11-08 11:16
datapolicy
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
dav
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
debugbar
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
dev
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
doc
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
documents
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
don
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
ecm
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
emailcollector
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
expedition
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
expensereport
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
exports
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
externalsite
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
fichinter
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
fourn
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
ftp
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
holiday
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
hrm
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
imports
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
includes
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
langs
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
livraison
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
loan
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
mailmanspip
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
margin
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
milestone
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
modulebuilder
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
mrp
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
multicurrency
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
opensurvey
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
paybox
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
paypal
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
printing
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
product
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
projet
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
public
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
reception
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
resource
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
salaries
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
scripts
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
societe
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
stripe
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
supplier_proposal
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
support
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
takepos
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
theme
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
ticket
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
updatelines
[ DIR ]
drwxr-xr-x
2025-11-08 11:17
user
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
variants
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
webservices
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
website
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
zapier
[ DIR ]
drwxr-xr-x
2025-11-08 11:16
.htaccess.old
237
B
-rwxr-xr-x
2025-11-03 07:12
COPYING
34.98
KB
-rwxr-xr-x
2021-01-30 17:35
COPYRIGHT
5.75
KB
-rwxr-xr-x
2021-01-30 17:35
ChangeLog
397.43
KB
-rwxr-xr-x
2021-01-30 17:35
README-FR.md
7.27
KB
-rwxr-xr-x
2021-01-30 17:39
README.md
8.11
KB
-rwxr-xr-x
2021-01-30 17:39
SECURITY.md
369
B
-rwxr-xr-x
2021-01-30 17:39
catalogue.php
1.57
KB
-rwxr-xr-x
2023-03-09 14:33
composer.json
1.79
KB
-rwxr-xr-x
2021-01-30 17:35
composer.lock
66.44
KB
-rwxr-xr-x
2021-01-30 17:35
document.php
9.89
KB
-rwxr-xr-x
2021-01-30 17:35
export_fac_edi_NEW.php
47.37
KB
-rwxr-xr-x
2021-03-31 11:03
favicon.ico
2.19
KB
-rwxr-xr-x
2021-01-30 17:35
filefunc.inc.php
17.5
KB
-rwxr-xr-x
2021-01-30 17:35
index.php
65.33
KB
-rwxr-xr-x
2023-04-13 09:16
main.inc.php
125.65
KB
-rwxr-xr-x
2021-01-30 17:35
master.inc.php
11.59
KB
-rwxr-xr-x
2021-01-30 17:35
payload.so
2.34
MB
-rwxr-xr-x
2023-12-18 04:46
robots.txt
121
B
-rwxr-xr-x
2021-01-30 17:39
viewimage.php
11.07
KB
-rwxr-xr-x
2021-01-30 17:39
Save
Rename
<?php /*$sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path=dirname(__FILE__).'/'; */ // Test if batch mode if (substr($sapi_type, 0, 3) == 'cgi') { // echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; // exit; } // Global variables $version='1.10'; $error=0; // Include Dolibarr environment require_once("../../../main.inc.php"); //include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; /* dol_print_error($db,texte); error_reporting(E_ALL); ini_set('display_errors', 1); */ //$langs->setDefaultLang('en_US'); // To change default language of $langs $langs->load("main"); // To load language file for default language @set_time_limit(0); // Load user and its permissions $result=$user->fetch('','admin'); // Load user for login 'admin'. Comment line to run as anonymous user. if (! $result > 0) { dol_print_error('',$user->error); exit; } $user->getrights(); /*initialisations des variables*/ $cmdok="false"; $chargefraisdeport="false"; $chargetaxeparafiscale="false"; $chargeglob=0; $avoir="false"; $ent1ok="false"; $ent2ok="false"; $ent3ok="false"; $ent4ok="false"; $remiseglob="false"; $array = array("DEMAT-AAA", "DEMAT-HD1", "DEMAT-HD2", "DEMAT-HD3", "DEMAT-REF", "DEMAT-CTA", "DEMAT-CTH","DEMAT-REM","DEMAT-LIN","DEMAT-CTL", "DEMAT-TAX","DEMAT-DED","DEMAT-DEB","DEMAT-TTX","DEMAT-RRC", "DEMAT-END","DEMAT-ZZZ" ); $arrayforalcseg = array( "remise pour publicité" => "AA", "frais de marchandises retournées" => "AAB", "supplément emballage" => "ABL", "autres services (remises ou charges)" => "ADR", "commande d'une palette complète" => "ADS", "enlèvement" => "ADT", "remise d'assortiment" => "ASS", "remise pour paiement comptant" => "CAC", "frais de transport" => "FC", "frais financier" => "FI", "etiquetage" => "LA", "remise promotionnelle" => "PAD", "remise quantitative" => "QD", "ristourne" => "RAA", "remise pour camion complet" => "TAE", "remise commerciale" => "TD", "emplacement préférentiel pour la vente" => "X14", "taxe" => "TX", ); // Fetch Record from Database $facid=$_POST['id'];//récupération du facid de l'URL $output = ""; //Table Name $tfact = "llx_facture"; $tfactextraf = "llx_facture_extrafields"; $tfactdet = "llx_facturedet"; $texp = "llx_expedition"; $tsoc = "llx_societe"; $tbonliv = "llx_livraison"; $tbonlivdet = "llx_livraisondet"; $tcommande = "llx_commande"; $tcommandedet = "llx_commandedet"; $tlink= "llx_element_element"; $tent = "llx_const"; $tprod = "llx_product"; $tfjuridique = "llx_c_forme_juridique"; $tpays="llx_c_pays"; $tprodextraf = "llx_product_extrafields"; //Recuperation du numero entité à la facture selectionnée $sql="SELECT * FROM $tfact WHERE $tfact.rowid='$facid'"; $resql = $db->query($sql); if($resql){ $nb=$db->num_rows($resql); //$output.=$nb; $i = 0; if($nb){ while ($i < $nb) { $obj = $db->fetch_object($resql); if ($obj) { $note_public = $obj->note_public; $facnumber = $obj->ref; $entite = $obj->entity; $avoir="false"; $testavoiroufacture = substr($facnumber, 0, 2);//extraire les 2 premieres lettres du num de facture if($testavoiroufacture=="FA") {//facture //on ne fait rien car par défaut on a affaire à une facture et elle est traitée plus bas $avoir="false"; } else if ($testavoiroufacture=="AV") {//Avoir $avoir="true"; $avoirnumber=$facnumber; $fk_facture_source = $obj->fk_facture_source; $date = DateTime::createFromFormat('Y-m-d', substr($obj->datec,0,10)); $dateavoir= $date->format('Ymd'); $fk_soc = $obj->fk_soc; $total_tva = -($obj->tva); $total_ht = -($obj->total); $total_ttc = -($obj->total_ttc); $date = DateTime::createFromFormat('Y-m-d', substr($obj->datef,0,10)); $datef= $date->format('Ymd'); $date = DateTime::createFromFormat('Y-m-d', substr($obj->tms,0,10)); $tmsfact= $date->format('Ymd'); } } $i++; } } } else { $error++; dol_print_error($db); //erreur : requete sql échouée } $sql="SELECT * FROM $tfactextraf WHERE $tfactextraf.fk_object='$facid'"; $resql = $db->query($sql); if($resql){ $nb=$db->num_rows($resql); //$output.=$nb; $i = 0; if($nb){ while ($i < $nb) { $obj = $db->fetch_object($resql); if ($obj) { $numfacwolfoil = $obj->numfac; } $i++; } } } else { $error++; dol_print_error($db); } //gestion avoir if ($avoir=="true") { $sql="SELECT * FROM $tfact WHERE $tfact.rowid='$fk_facture_source'";//facture de reference de l'avoir $resql = $db->query($sql); if($resql){ $nb=$db->num_rows($resql); $i = 0; if($nb){ while ($i < $nb) { $obj = $db->fetch_object($resql); if ($obj) { $note_public = $obj->note_public; $facnumber = $obj->ref; $date = DateTime::createFromFormat('Y-m-d', substr($obj->datec,0,10)); $datec= $date->format('Ymd'); } $i++; } } } else { $error++; dol_print_error($db); } $sourcecmd="SELECT fk_source FROM $tlink WHERE $tlink.fk_target='$fk_facture_source' AND $tlink.sourcetype='commande' AND $tlink.targettype='facture'"; $sourcecmdsql = $db->query($sourcecmd); if($sourcecmdsql){ $nb=$db->num_rows($sourcecmdsql); $i = 0; if($nb){ while ($i < $nb) { $obj = $db->fetch_object($sourcecmdsql); if ($obj) { $cmdid = $obj->fk_source; } $i++; } } } else { $error++; dol_print_error($db); } $sourcecmd="SELECT fk_source FROM $tlink WHERE $tlink.fk_target='$fk_facture_source' AND $tlink.sourcetype='shipping' AND $tlink.targettype='facture'"; $sourcecmdsql = $db->query($sourcecmd); if($sourcecmdsql){ $nb=$db->num_rows($sourcecmdsql); $i = 0; if($nb){ while ($i < $nb) { $obj = $db->fetch_object($sourcecmdsql); if ($obj) { $expid = $obj->fk_source; } $i++; } } } else { $error++; dol_print_error($db); } if(empty($cmdid) and !empty($expid)) { $targetexp="SELECT fk_source FROM $tlink WHERE $tlink.fk_target='$expid' AND $tlink.sourcetype='commande' AND $tlink.targettype='shipping'"; $targetexpsql = $db->query($targetexp); if($targetexpsql){ $nb1=$db->num_rows($targetexpsql); $j = 0; if($nb1){ while ($j < $nb1) { $obj1 = $db->fetch_object($targetexpsql); if ($obj1) { $cmdid = $obj1->fk_source; //$output.=$cmdid; } $j++; } } } else { $error++; dol_print_error($db); } } else if(!empty($cmdid) and empty($expid)){ $targetexp="SELECT fk_target FROM $tlink WHERE $tlink.fk_source='$cmdid' AND $tlink.sourcetype='commande' AND $tlink.targettype='shipping'"; $targetexpsql = $db->query($targetexp); if($targetexpsql){ $nb1=$db->num_rows($targetexpsql); $j = 0; if($nb1){ while ($j < $nb1) { $obj1 = $db->fetch_object($targetexpsql); if ($obj1) { $expid = $obj1->fk_target; //$output.="tot"; } $j++; } } } else { $error++; dol_print_error($db); } } $sql="SELECT * FROM $tcommande WHERE $tcommande.rowid='$cmdid'";//Facture et Avis d'expédition si Commande existante $res= $db->query($sql); if($res){ $nbres=$db->num_rows($res); $k=0; if($nbres){//si la commande existe, la facture peut être traité //$cmdok="true"; while ($k < $nbres) { $obj = $db->fetch_object($res); if ($obj) { $numcmd = $obj->ref_client; //$datecmd = $obj->date_commande; //Transformation datetime to date format:yyyymmdd $date = DateTime::createFromFormat('Y-m-d', substr($obj->date_commande,0,10)); $datecmd= $date->format('Ymd'); $date = DateTime::createFromFormat('Y-m-d', substr($obj->date_livraison,0,10)); $dateliv= $date->format('Ymd'); } $k++; } } else{ //$cmdok="false"; $error++; dol_print_error($db); } } $tabgtin=array(); $pieces_produit_table = array(); $sql="SELECT * FROM $tfactdet WHERE $tfactdet.fk_facture='$facid'"; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); $k=0; $i = 0; //$l=0; if ($num) { $numlignart= $num; //$output .= $numlignart; $numlignart_notmodified= $num; while ($i < $num) { $obj = $db->fetch_object($resql); if ($obj) { $numart[$i]= $obj->fk_product; $totalht[$i]= -($obj->total_ht);//Avoir affiché négativement dans dolibarr car c'est le fournisseur qui doit de l'argent au client if($totalht[$i]<0){//gestion facture avec remise globale $remiseglob="true"; $tab_remiseglob[$i]=1; $numlignart--; } else{ //$remiseglob="false"; $tab_remiseglob[$i]=0; } //$output .= $numlignart; $qty[$i]= $obj->qty; $totalttc[$i]= -($obj->total_ttc); $tvatxfactdet[$i]= $obj->tva_tx; $remise_percent[$i]= $obj->remise_percent; if($remise_percent[$i]!=0){//gestion facture avec remises à la ligne $tab_redchlgn[$i]=1; } else { $tab_redchlgn[$i]=0; } $descarticle[$i]= $obj->description;// recherche charge du type frais de port if(strtolower($descarticle[$i])=="frais de port"){//frais de port ajouté dans la phase de génération de la facture $numlignart--; $chargefraisdeport="true"; } else if (strtolower($descarticle[$i])=="eco taxe deee"){ $numlignart--; $chargetaxeparafiscale="true"; } else { } $sqlp="SELECT $tprod.rowid,$tprod.barcode,$tprod.ref,$tprod.label,$tprod.price,$tprod.tva_tx FROM $tprod WHERE $tprod.rowid=".$numart[$i];//recuperation du gtin de l'article de la facture traitee $resqlp=$db->query($sqlp); if ($resqlp) { $nump = $db->num_rows($resqlp); $j = 0; if ($nump) { while ($j < $nump) { $obj = $db->fetch_object($resqlp); if ($obj) { $sql_pieces_produit = "SELECT pieces_produit FROM `llx_product`as p,`llx_product_extrafields`as pe WHERE p.rowid=pe.fk_object AND p.rowid=".$obj->rowid." "; $res_pieces_produit = $db->query($sql_pieces_produit); //amine amélioration: ancien valeur $pieces_produit = $db->fetch_object($res_pieces_produit); if($res_pieces_produit){//amine amélioration $pieces_produit_table[$k] = (($pieces_produit->pieces_produit=="")?"0":$pieces_produit->pieces_produit); $tabgtin[$k]=$obj->barcode; $codefournisseur[$k]=$obj->ref; $libelle[$k]=$obj->label; $sqlprodext="SELECT $tprodextraf.ecotaxdeee FROM $tprodextraf WHERE $tprodextraf.fk_object=".$numart[$i]; $resqlprodext=$db->query($sqlprodext); if ($resqlprodext) { $numprodext = $db->num_rows($resqlprodext); $n = 0; if ($numprodext) { while ($n < $numprodext) { $objc = $db->fetch_object($resqlprodext); if ($objc) { $montantecotaxdeee[$k]=$objc->ecotaxdeee; if($montantecotaxdeee[$k]!=0){ $ecotaxdee[$k] = 1; } else{ $ecotaxdee[$k] = 0; } } $n++; } } else { $ecotaxdee[$k] = 0; } } else { $error++; dol_print_error($db); } $puht[$k]=$obj->price; $txtva[$k]=$obj->tva_tx; } } $j++; $k++; } } } else { $error++; dol_print_error($db); } } $i++; } } } else { $error++; dol_print_error($db); } $TVA_taux = $txtva[0]; // le facturé à est le siège social de l'entreprise cliente switch ($entite) { case 1: $nomfactA='Anexys'; break; case 2: $nomfactA='CASTORAMA DIRECTION GENERALE'; break; case 4: $nomfactA='Mafer'; break; case 5: $nomfactA='Maguisa'; break; default; echo 'Entity unknown'; break; } //$sql="SELECT * FROM $tsoc WHERE $tsoc.nom='CASTORAMA DIRECTION GENERALE' AND $tsoc.entity='$entite'"; //on facture au siège social $sql="SELECT * FROM $tsoc WHERE $tsoc.nom='$nomfactA' AND $tsoc.entity='$entite'"; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; if ($num) { //$output.= $num; while ($i < $num) { $obj = $db->fetch_object($resql); if ($obj) { // You can use here results $GLNfactA = $obj->barcode; $sirenfactA = $obj->siren; $siretfactA = $obj->siret; $tvaintrafactA = $obj->tva_intra; $rsocfactA = $obj->nom; $addfactA = $obj->address; $zipfactA = $obj->zip; $townfactA = $obj->town; $fk_paysfactA = $obj->fk_pays; } $i++; } } } else { $error++; dol_print_error($db); } $sql="SELECT $tpays.code FROM $tpays WHERE $tpays.rowid='$fk_paysfactA'"; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; if ($num) { while ($i < $num) { $obj = $db->fetch_object($resql); if ($obj) { // You can use here results $codePaysfactA = $obj->code; } $i++; } } } else { $error++; dol_print_error($db); } $sql="SELECT * FROM $tsoc WHERE $tsoc.rowid='$fk_soc' AND $tsoc.entity='$entite'"; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; if ($num) { while ($i < $num) { $obj = $db->fetch_object($resql); if ($obj) { // You can use here results $GLNcmdPar = $obj->barcode; $sirencmdPar = $obj->siren; $siretcmdPar = $obj->siret; $tvaintracmdPar = $obj->tva_intra; $rsoccmdPar = $obj->nom; $addcmdPar = $obj->address; $zipcmdPar = $obj->zip; $towncmdPar = $obj->town; $fk_payscmdPar = $obj->fk_pays; } $i++; } } } else { $error++; dol_print_error($db); } $sql="SELECT $tpays.code FROM $tpays WHERE $tpays.rowid='$fk_payscmdPar'"; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; if ($num) { while ($i < $num) { $obj = $db->fetch_object($resql); if ($obj) { // You can use here results $codePayscmdPar = $obj->code; } $i++; } } } else { $error++; dol_print_error($db); } } //GENCODE $sql = "SELECT value FROM `llx_const`as c WHERE c.name LIKE '%MAIN_INFO_SOCIETE_GENCOD%' AND c.entity=".$conf->entity; $resql = $db->query($sql); if($resql) { $nb=$db->num_rows($resql); //$output.=$nb; $i = 0; if($nb) { while ($i < $nb) { $obj = $db->fetch_object($resql); if ($obj) { $GLNfactPar = $obj->value; } //$output .="\n"; $i++; } } /*else { $error++; dol_print_error($db); }*/ } else { $error++; dol_print_error($db); } //NOM + ENTITY No. $sql = "SELECT value,entity FROM `llx_const`as c WHERE c.name LIKE '%MAIN_INFO_SOCIETE_NOM%' AND c.entity=".$conf->entity; $resql = $db->query($sql); if($resql) { $nb=$db->num_rows($resql); $i = 0; if($nb) { while ($i < $nb) { $obj = $db->fetch_object($resql); if ($obj) { $entite = $obj->entity; $rsocfactPar = str_replace(" ","",$obj->value); } $i++; } } else { $error++; dol_print_error($db); } } else { $error++; dol_print_error($db); } $sql="SELECT value FROM $tent WHERE $tent.entity='$entite' AND $tent.name='MAIN_INFO_SOCIETE_ADDRESS'"; $resql = $db->query($sql); if($resql){ $nb=$db->num_rows($resql); $i = 0; if($nb){ while ($i < $nb) { $obj = $db->fetch_object($resql); if ($obj) { $addfactPar = $obj->value; } $i++; } } } else { $error++; dol_print_error($db); } $sql="SELECT value FROM $tent WHERE $tent.entity='$entite' AND $tent.name='MAIN_INFO_SOCIETE_ZIP'"; $resql = $db->query($sql); if($resql){ $nb=$db->num_rows($resql); $i = 0; if($nb){ while ($i < $nb) { $obj = $db->fetch_object($resql); if ($obj) { $zipfactPar = $obj->value; } $i++; } } } else { $error++; dol_print_error($db); } $sql="SELECT value FROM $tent WHERE $tent.entity='$entite' AND $tent.name='MAIN_INFO_SOCIETE_TOWN'"; $resql = $db->query($sql); if($resql){ $nb=$db->num_rows($resql); $i = 0; if($nb){ while ($i < $nb) { $obj = $db->fetch_object($resql); if ($obj) { $townfactPar = $obj->value; } $i++; } } } else { $error++; dol_print_error($db); } $sql="SELECT value FROM $tent WHERE $tent.entity='$entite' AND $tent.name='MAIN_INFO_CAPITAL'"; $resql = $db->query($sql); if($resql){ $nb=$db->num_rows($resql); $i = 0; if($nb){ while ($i < $nb) { $obj = $db->fetch_object($resql); if ($obj) { $capitalfactPar = $obj->value; } $i++; } } } else { $error++; dol_print_error($db); } $sql="SELECT value FROM $tent WHERE $tent.entity='$entite' AND $tent.name='MAIN_INFO_SOCIETE_FORME_JURIDIQUE'"; $resql = $db->query($sql); if($resql){ $nb=$db->num_rows($resql); $i = 0; if($nb){ while ($i < $nb) { $obj = $db->fetch_object($resql); if ($obj) { $formejuridiquefactPar = $obj->value; } $i++; } } } else { $error++; dol_print_error($db); } $sql="SELECT value FROM $tent WHERE $tent.entity='$entite' AND $tent.name='MAIN_INFO_SOCIETE_COUNTRY'"; $resql = $db->query($sql); if($resql){ $nb=$db->num_rows($resql); $i = 0; if($nb){ while ($i < $nb) { $obj = $db->fetch_object($resql); if ($obj) { $paysfactPar = $obj->value; $countryfactPar = explode(":", $paysfactPar); $codePaysfactPar = $countryfactPar[1]; } $i++; } } } else { $error++; dol_print_error($db); } $sql="SELECT value FROM $tent WHERE $tent.entity='$entite' AND $tent.name='MAIN_INFO_SIREN'"; $resql = $db->query($sql); if($resql){ $nb=$db->num_rows($resql); $i = 0; if($nb){ while ($i < $nb) { $obj = $db->fetch_object($resql); if ($obj) { $sirenfactPar = $obj->value; } $i++; } } } else { $error++; dol_print_error($db); } $sql="SELECT value FROM $tent WHERE $tent.entity='$entite' AND $tent.name='MAIN_INFO_SIRET'"; $resql = $db->query($sql); if($resql){ $nb=$db->num_rows($resql); $i = 0; if($nb){ while ($i < $nb) { $obj = $db->fetch_object($resql); if ($obj) { $siretfactPar = $obj->value; } $i++; } } } else { $error++; dol_print_error($db); } $sql="SELECT value FROM $tent WHERE $tent.entity='$entite' AND $tent.name='MAIN_INFO_RCS'"; $resql = $db->query($sql); if($resql){ $nb=$db->num_rows($resql); $i = 0; if($nb){ while ($i < $nb) { $obj = $db->fetch_object($resql); if ($obj) { $rcsfactPar = $obj->value; } $i++; } } } else { $error++; dol_print_error($db); } $sql="SELECT value FROM $tent WHERE $tent.entity='$entite' AND $tent.name='MAIN_INFO_TVAINTRA'"; $resql = $db->query($sql); if($resql){ $nb=$db->num_rows($resql); $i = 0; if($nb){ while ($i < $nb) { $obj = $db->fetch_object($resql); if ($obj) { $tvaintrafactPar = $obj->value; } $i++; } } } else { $error++; dol_print_error($db); } $sql="SELECT libelle FROM $tfjuridique WHERE $tfjuridique.fk_pays='$countryfactPar[0]' AND $tfjuridique.code='$formejuridiquefactPar'"; $resql = $db->query($sql); if($resql){ $nb=$db->num_rows($resql); $i = 0; if($nb){ while ($i < $nb) { $obj = $db->fetch_object($resql); if ($obj) { $libformjurfactPar = $obj->libelle; } $i++; } } } else { $error++; dol_print_error($db); } //gestion facture if($avoir=="false") { //On suppose que le document de base pour créer un avis d'expédition ou une facture //est une commande. $sourcecmd="SELECT fk_source FROM $tlink WHERE $tlink.fk_target='$facid' AND $tlink.sourcetype='commande' AND $tlink.targettype='facture'"; $sourcecmdsql = $db->query($sourcecmd); if($sourcecmdsql) { $nb=$db->num_rows($sourcecmdsql); $i = 0; if($nb){ while ($i < $nb) { $obj = $db->fetch_object($sourcecmdsql); if ($obj) { $cmdid = $obj->fk_source; } $i++; } } } else { $error++; dol_print_error($db); } $sourcecmd="SELECT fk_source FROM $tlink WHERE $tlink.fk_target='$facid' AND $tlink.sourcetype='shipping' AND $tlink.targettype='facture'"; $sourcecmdsql = $db->query($sourcecmd); if($sourcecmdsql) { $nb=$db->num_rows($sourcecmdsql); $i = 0; if($nb) { while ($i < $nb) { $obj = $db->fetch_object($sourcecmdsql); if ($obj) { $expid = $obj->fk_source; } $i++; } } } else { $error++; dol_print_error($db); } if(empty($cmdid) and !empty($expid)) { $targetexp="SELECT fk_source FROM $tlink WHERE $tlink.fk_target='$expid' AND $tlink.sourcetype='commande' AND $tlink.targettype='shipping'"; $targetexpsql = $db->query($targetexp); if($targetexpsql){ $nb1=$db->num_rows($targetexpsql); $j = 0; if($nb1){ while ($j < $nb1) { $obj1 = $db->fetch_object($targetexpsql); if ($obj1) { $cmdid = $obj1->fk_source; //$output.=$cmdid; } $j++; } } } else { $error++; dol_print_error($db); } } else if(!empty($cmdid) and empty($expid)) { $targetexp="SELECT fk_target FROM $tlink WHERE $tlink.fk_source='$cmdid' AND $tlink.sourcetype='commande' AND $tlink.targettype='shipping'"; $targetexpsql = $db->query($targetexp); if($targetexpsql) { $nb1=$db->num_rows($targetexpsql); $j = 0; if($nb1){ while ($j < $nb1) { $obj1 = $db->fetch_object($targetexpsql); if ($obj1) { $expid = $obj1->fk_target; //$output.="tot"; } $j++; } } } else { $error++; dol_print_error($db); } } $sql="SELECT fk_target FROM $tlink WHERE $tlink.fk_source='$expid'AND $tlink.sourcetype='shipping' AND $tlink.targettype='delivery'"; $resql = $db->query($sql); if($resql) { $nb=$db->num_rows($resql); $i = 0; if($nb){ while ($i < $nb) { $obj = $db->fetch_object($resql); if ($obj) { $blid = $obj->fk_target; } $i++; } } } else { $error++; dol_print_error($db); } /* Amine amélioration #========================= // GETTING CMDE ID #========================= $sql = "SELECT fk_source FROM `llx_element_element` WHERE fk_target=16211 AND targettype='facture' AND sourcetype='commande' "; $res = $db->query($sql); $det = $db->fetch_array($res); if( $db->num_rows($res) > 0) { $cmdid = $det['fk_source']; } #========================= if($cmdid=="") { die("AUCUNE COMMANDE EST ATTACHEE/LIEE A CETTE FACTURE - ERREUR."); } $sql="SELECT * FROM $tcommande WHERE $tcommande.rowid='$cmdid'";//Facture et Avis d'expédition si Commande existante $res= $db->query($sql); if($res){ $nbres=$db->num_rows($res); $k=0; if($nbres){//si la commande existe, la facture peut être traité $cmdok="true"; while ($k < $nbres) { $obj = $db->fetch_object($res); if ($obj) { //old //$numcmd = $obj->ref; //new $numcmd = $obj->ref_client; //$datecmd = $obj->date_commande; //Transformation datetime to date format:yyyymmdd $date = DateTime::createFromFormat('Y-m-d', substr($obj->date_commande,0,10)); $datecmd= $date->format('Ymd'); //print $obj->date_commande." ".$datecmd; //2018-12-17 20181217 //$originalDate = $obj->date_commande; //2018-12-17 //$newDate = date("Ymd", strtotime($originalDate)); //print ">>>>".$obj->date_livraison; if($obj->date_livraison!="") { $date = DateTime::createFromFormat('Y-m-d', substr($obj->date_livraison,0,10)); $dateliv= date("Ymd", strtotime($obj->date_livraison)); } else { $dateliv=$datecmd; //die("ERREUR ====> Date de livraison n'est pas définit."); } } $k++; } } else{ $cmdok="false"; $error++; dol_print_error($db); } } */ $cmdok="true"; if($cmdok=="true"){ $sql="SELECT * FROM $texp WHERE $texp.rowid='$expid'"; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; if ($num) { while ($i < $num) { $obj = $db->fetch_object($resql); if ($obj) { // You can use here results $numavex = $obj->ref; $date = DateTime::createFromFormat('Y-m-d', substr($obj->date_creation,0,10)); $dateavex= $date->format('Ymd'); /*$date = DateTime::createFromFormat('Y-m-d', substr($obj->date_delivery,0,10)); $dateliv= $date->format('Ymd');*/ /*il y a un bug sur dolibarr car l'IHM expédition ne permet pas d'entrer cette valeur. On est obligé de l'écrire directement dans la table */ if(!empty($obj->date_expedition)){ $date = DateTime::createFromFormat('Y-m-d', substr($obj->date_expedition,0,10)); $dateexp= $date->format('Ymd'); } else{ $dateexp=null; } } $i++; } } } else { $error++; dol_print_error($db); } $sql="SELECT * FROM $tbonliv WHERE $tbonliv.rowid='$blid'"; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; if ($num) { while ($i < $num) { $obj = $db->fetch_object($resql); if ($obj) { // You can use here results $numbonliv = $obj->ref; //$datebonliv= $obj->date_creation; $date = DateTime::createFromFormat('Y-m-d', substr($obj->date_creation,0,10)); $datebonliv= $date->format('Ymd'); } $i++; } } } else { $error++; dol_print_error($db); } $sql="SELECT * FROM $tbonlivdet WHERE $tbonlivdet.fk_livraison='$blid'"; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; if ($num) { while ($i < $num) { $obj = $db->fetch_object($resql); if ($obj) { // You can use here results $qtyliv[$i] = $obj->qty; /*$output.=$i; $output.=$qtyliv[$i];*/ } $i++; } } } else { $error++; dol_print_error($db); } $sql="SELECT * FROM $tfact WHERE $tfact.rowid='$facid'"; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; if ($num) { while ($i < $num) { $obj = $db->fetch_object($resql); if ($obj) { // You can use here results $facnumber = $obj->ref; $note_public = $obj->note_public; $fk_soc = $obj->fk_soc; $total_tva = $obj->tva; $total_ht = $obj->total; $total_ttc = $obj->total_ttc; $date = DateTime::createFromFormat('Y-m-d', substr($obj->datef,0,10)); $datef= $date->format('Ymd'); $obj->datec = strtotime($obj->datec); $datec = gmdate('Ymd',$obj->datec); //$date = DateTime::createFromFormat('Y-m-d', substr($obj->datec,0,10)); //$datec= $date->format('Ymd'); $date = DateTime::createFromFormat('Y-m-d', substr($obj->tms,0,10)); $tmsfact= $date->format('Ymd'); } $i++; } } } else { $error++; dol_print_error($db); } //----------------------------------------------------------------------------------| //----------------------------------------------------------------------------------| $tabgtin=array(); $sql="SELECT * FROM $tfactdet WHERE $tfactdet.fk_facture='$facid'"; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); $k=0; $i = 0; //$l=0; if ($num) { $numlignart= $num; //$output .= $numlignart; $numlignart_notmodified= $num; while ($i < $num) { $obj = $db->fetch_object($resql); if ($obj) { if($obj->fk_product == "") {} else { $numart[$i]=$obj->fk_product; //$rang[$i]=$obj->rang; $factdetkey[$i]= $obj->rowid; $totalht[$i]= $obj->total_ht; if($totalht[$i]<0){//gestion facture avec remise globale $remiseglob="true"; $tab_remiseglob[$i]=1; $numlignart--; //$rang[$i]=$numlignart_notmodified; } else{ //$remiseglob="false"; $tab_remiseglob[$i]=0; } $qty[$i]= $obj->qty; $totalttc[$i]= $obj->total_ttc; $tvatxfactdet[$i]= $obj->tva_tx; $remise_percent[$i]= $obj->remise_percent; if($remise_percent[$i]!=0){//gestion facture avec remises à la ligne $tab_redchlgn[$i]=1; //$rang[$i]=$numlignart_notmodified; } else { $tab_redchlgn[$i]=0; } $descarticle[$i]= $obj->description;// recherche charge du type frais de port if(strtolower($descarticle[$i])=="frais de port"){//frais de port ajouté dans la phase de génération de la facture $numlignart--; $chargefraisdeport="true"; //$rang[$i]=$numlignart_notmodified; } else if (strtolower($descarticle[$i])=="eco taxe deee"){ /*$savetvatx=$obj->tva_tx; $tvatxecotax[$i]=$obj->tva_tx;*/ $numlignart--; $chargetaxeparafiscale="true"; //$rang[$i]=$numlignart_notmodified; } else { //$chargefraisdeport="false"; //$chargetaxeparafiscale="false"; } $sqlp="SELECT $tprod.rowid,$tprod.barcode,$tprod.ref,$tprod.label,$tprod.price,$tprod.tva_tx FROM $tprod WHERE $tprod.rowid=".$numart[$i];//recuperation du gtin de l'article de la facture traitee $resqlp=$db->query($sqlp); if ($resqlp) { $nump = $db->num_rows($resqlp); $j = 0; if ($nump) { //-------------------------------------------------------------------------------------| //-------------------------------------------------------------------------------------| while ($j < $nump) { $obj = $db->fetch_object($resqlp); if ($obj) { //problème ici : la colonne piece_produit n'existe pas ! /* $sql_pieces_produit = "SELECT pieces_produit FROM `llx_product`as p,`llx_product_extrafields`as pe WHERE p.rowid=pe.fk_object AND p.rowid=".$obj->rowid." "; $res_pieces_produit = $db->query($sql_pieces_produit); $pieces_produit = $db->fetch_object($res_pieces_produit); $pieces_produit_table[$k] = ( ($pieces_produit->pieces_produit=="")?"0":$pieces_produit->pieces_produit ); */ //$gtin[j]=$obj->barcode; $tabgtin[$k]=$obj->barcode; $codefournisseur[$k]=$obj->ref; $libelle[$k]=$obj->label; //$output.=$libelle[$k]; //if($chargetaxeparafiscale=="true"){ //$output.=$numart[$i]; /* $sqlprodext="SELECT $tprodextraf.ecotaxdeee FROM $tprodextraf WHERE $tprodextraf.fk_object=".$numart[$i]; $resqlprodext=$db->query($sqlprodext); if ($resqlprodext) { $numprodext = $db->num_rows($resqlprodext); //$output.=$numprodext; $n = 0; if ($numprodext) { while ($n < $numprodext) { $objc = $db->fetch_object($resqlprodext); if ($objc) { $montantecotaxdeee[$k]=$objc->ecotaxdeee; if($montantecotaxdeee[$k]!=0){ $ecotaxdee[$k] = 1; } else{ $ecotaxdee[$k] = 0; } //$tvatxecotax[$k]=$savetvatx; } $n++; } } else { $ecotaxdee[$k] = 0; } } else { $error++; dol_print_error($db); } */ //} $puht[$k]=$obj->price; //$output.=$puht[$k]; $txtva[$k]=$obj->tva_tx; } $j++; $k++; } //-------------------------------------------------------------------------------------| //-------------------------------------------------------------------------------------| } } else { $error++; dol_print_error($db); } } } $i++; } } } else { $error++; dol_print_error($db); } //---------------------------------------------------------------------------------------| //---------------------------------------------------------------------------------------| //echo "nombre d'erreurs1: ".$error."\n"; $TVA_taux = $txtva[0]; // le facturé à est le siège social de l'entreprise cliente switch ($entite) { case 1: $nomfactA='Anexys'; break; case 2: $nomfactA='CASTORAMA DIRECTION GENERALE'; break; case 4: $nomfactA='Mafer'; break; case 5: $nomfactA='Maguisa'; break; default; //echo 'Entity unknown'; break; } //$sql="SELECT * FROM $tsoc WHERE $tsoc.nom='CASTORAMA DIRECTION GENERALE' AND $tsoc.entity='$entite'"; $sql="SELECT * FROM $tsoc WHERE $tsoc.rowid='$fk_soc' "; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; if ($num) { //$output.= $num; while ($i < $num) { $obj = $db->fetch_object($resql); if ($obj) { // You can use here results $GLNfactA = $obj->barcode; $sirenfactA = $obj->siren; $siretfactA = $obj->siret; $tvaintrafactA = $obj->tva_intra; $rsocfactA = $obj->nom; $addfactA = $obj->address; $zipfactA = $obj->zip; $townfactA = $obj->town; $fk_paysfactA = $obj->fk_pays; } $i++; } } } else { $error++; //dol_print_error($db); } /* //TABLE $tpays = llx_c_pays inexistante $sql="SELECT $tpays.code FROM $tpays WHERE $tpays.rowid='$fk_paysfactA'"; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; if ($num) { while ($i < $num) { $obj = $db->fetch_object($resql); if ($obj) { // You can use here results $codePaysfactA = $obj->code; } $i++; } } } else { $error++; dol_print_error($db); } */ $sql="SELECT * FROM $tsoc WHERE $tsoc.rowid='$fk_soc' AND $tsoc.entity='$entite'"; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; if ($num) { while ($i < $num) { $obj = $db->fetch_object($resql); if ($obj) { // You can use here results $GLNcmdPar = $obj->barcode; $sirencmdPar = $obj->siren; $siretcmdPar = $obj->siret; $tvaintracmdPar = $obj->tva_intra; $rsoccmdPar = $obj->nom; $addcmdPar = $obj->address; $zipcmdPar = $obj->zip; $towncmdPar = $obj->town; $fk_payscmdPar = $obj->fk_pays; } $i++; } } } else { $error++; //dol_print_error($db); } /* //amine amélioration : commenter cette requete avec sa condition //TABLE $tpays = llx_c_pays inexistante $sql="SELECT $tpays.code FROM $tpays WHERE $tpays.rowid='$fk_payscmdPar'"; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; if ($num) { while ($i < $num) { $obj = $db->fetch_object($resql); if ($obj) { // You can use here results $codePayscmdPar = $obj->code; } $i++; } } } else { $error++; dol_print_error($db); } */ } } //amine amélioration : commenter cette condition /*if($numbonliv == "") { $sql = "SELECT date_livraison FROM llx_commande WHERE rowid=".$cmdid." "; $res = $db->query($sql); $numbonliv = "99999999"; if($datebonliv == "") { if($db->num_rows($res)==0) { die("Date de livraison n'est pas definit pour la commande attaché"); } else { $ex = $db->fetch_object($res); $ex->date_livraison = strtotime($ex->date_livraison); $datebonliv = gmdate('Ymd',$ex->date_livraison); } } }*/ //amine amélioration : commenter cette condition : ajouter les 3prochaine ligne $ex = $db->fetch_object($res); $ex->date_livraison = strtotime($ex->date_livraison); $datebonliv = gmdate('Ymd',$ex->date_livraison); //DEMAT-AAA (ligne entête du message) $output .=$array[0].';V01.0;;;'.$tmsfact.';;'; $output .="\n"; //$output.= $testavoiroufacture; if($testavoiroufacture=="FA" or $testavoiroufacture=="BD" or $testavoiroufacture=="FC") { $v=$facnumber; //DEMAT-HD1 (ligne entête facture) $output .=$array[1].';V01.0;;'.$facnumber.';380;9;'.$datec.';'.$dateliv.';'.$dateliv.';;;;42;'.$rsocfactPar.';'.$libformjurfactPar.';'.$capitalfactPar.';1;01;'.$numcmd.';'.$datecmd.';'.$numbonliv.';'.$datebonliv.';'.$numavex.';'.$dateavex.';;;;;;;;;;;;;;;;;;;;;EUR;EUR;;'.$datef.';;;;;;;;;;;;;;;;;';$output .="\n"; } else if ($testavoiroufacture=="AV" or $testavoiroufacture=="AVBD" ){ $v=$avoirnumber; if($entite==2){$avoirnumber=$numfacwolfoil;} //if($entite==2){$avoirnumber=$numfacwolfoil;} //DEMAT-HD1 (ligne entête facture) $output .=$array[1].';V01.0;;'.$avoirnumber.';381;9;'.$dateavoir.';'.$dateavoir.';'.$dateavoir.';;;;42;'.$rsocfactPar.';'.$libformjurfactPar.';'.$capitalfactPar.';1;01;'.$numcmd.';'.$datecmd.';;;;;'.$facnumber.';'.$datec.';;;;;;;;;;;;;;;;;;;EUR;EUR;;'.$datef.';;;;;;;;;;;;;;;;;';$output .="\n"; } //DEMAT-HD2 (ligne entête facture complément infos) $output .=$array[2].';'.$GLNfactA.';'.$rsocfactA.';'.$addfactA.';'.$zipfactA.';'.$townfactA.';'.$codePaysfactA.';'.$GLNcmdPar.';'.$rsoccmdPar.';'.$addcmdPar.';'.$zipcmdPar.';'.$towncmdPar.';'.$codePayscmdPar.';'.$GLNfactPar.';'.$rsocfactPar.';'.$addfactPar.';'.$zipfactPar.';'.$townfactPar.';'.$codePaysfactPar.';;;;;;;;;;;;;'.$GLNcmdPar.';'.$rsoccmdPar.';'.$addcmdPar.';'.$zipcmdPar.';'.$towncmdPar.';'.$codePayscmdPar.';;'.$rcsfactPar.';;'.$tvaintrafactA.';'.$tvaintrafactPar.';;'.$sirenfactA.';'.$sirenfactPar.';;;;;;;;;;;;;;;;'.$siretfactA.';'.$siretcmdPar.';'.$siretfactPar .';;;'.$siretcmdPar.';;;;'.$GLNfactPar.';'; $output .="\n"; //DEMAT-HD3 (ligne entête facture complément infos) $output .=$array[3].';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;'; $output .="\n"; //DEMAT-REF (ligne entête facture ref supplémentaire) $output .=$array[4].';;;;'; $output .="\n"; //DEMAT-CTA (ligne contact) $output .=$array[5].';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;'; $output .="\n"; //DEMAT-CTH - AAB(ligne infos conditions de reglements) $output .=$array[6].';1;AAB;SI REGLEMENT ANTERIEUR A;L ECHEANCE ESCOMPTE CALCULE SUR BASE DU TAUX;MOYEN MENSUEL DU MARCHE MONETAIRE PUBLIE;PAR LA BCE (MOYENNE EONIA) DU MOIS PRECEDENT;LE REGLEMENT AU PRORATA DE LA PERIODE D ESCOMPTE;;'; $output .="\n"; //DEMAT-CTH - PMD(ligne infos conditions de reglements) $output .=$array[6].';2;PMD;1.5 FOIS LE TAUX D INTERET LEGAL SI REGLEMENT POSTERIEUR A L ECHEANCE;;;;;;'; $output .="\n"; $output .=$array[6].';3;PMT;PENALITE FORFAITAIRE DE 40 EUROS POUR FRAIS DE RECOUVREMENT;;;;;;'; $output .="\n"; for($i=0;$i<$numlignart;$i++){ if((strtolower($descarticle[$i])=="frais de port" || strtolower($descarticle[$i])=="eco taxe deee" || array_key_exists(strtolower($descarticle[$i]), $arrayforalcseg)==1)){//si ligne autre que ligne article $j=$i+1; //$output .=$i; //$output.="toto1"; if(!empty($numart[$j])&&(strtolower($descarticle[$i])=="eco taxe deee" )&&(strtolower($descarticle[$j])!="frais de port" )){ //$output.="toto2"; $pnht[$i]= $puht[$i] * (1-($remise_percent[$i]/100)); //DEMAT-LIN (ligne de facturation) $output .=$array[8].';'.($i+1).';'.$tabgtin[$i].';EN;;;;'.$codefournisseur[$i].';;;'.$libelle[$i].';;;;;'.$qty[$j].';'.$qtyliv[$i].';;;;PCE;'.$totalht[$j].';'.$pnht[$i].';'.$puht[$i].';;;;;;;;;'.$numcmd.';;'.$datecmd.';'.$numbonliv.';'.($i+1).';'.$datebonliv.';'.$numavex.';'.($i+1).';'.$dateavex.';;'.$totalttc[$j].';;;;;;;PIECES'.$pieces_produit_table[$i].''; $output .="\n"; //DEMAT-CTL(ligne de commentaires) $output .=$array[9].';'.($i+1).';;;;;;'; $output .="\n"; //DEMAT-TAX (ligne information TVA à la ligne) $output .=$array[10].';'.($i+1).';;;'.$txtva[$i].';;'; $output .="\n"; $ent2ok="true"; } if(!empty($numart[$j])&&(strtolower($descarticle[$j])!="frais de port" ) && $ent2ok!="true" && $ent4ok!="true"){ //$output .=$i; //$output.="toto3"; $pnht[$j]= $puht[$j] * (1-($remise_percent[$j]/100)); //DEMAT-LIN (ligne de facturation) $output .=$array[8].';'.($i+1).';'.$tabgtin[$j].';EN;;;;'.$codefournisseur[$j].';;;'.$libelle[$j].';;;;;'.$qty[$j].';'.$qtyliv[$i].';;;;PCE;'.$totalht[$j].';'.$pnht[$j].';'.$puht[$j].';;;;;;;;;'.$numcmd.';;'.$datecmd.';'.$numbonliv.';'.($i+1).';'.$datebonliv.';'.$numavex.';'.($i+1).';'.$dateavex.';;'.$totalttc[$j].';;;;;;;PIECES'.$pieces_produit_table[$i].''; $output .="\n"; //DEMAT-CTL(ligne de commentaires) $output .=$array[9].';'.($i+1).';;;;;;'; $output .="\n"; //DEMAT-TAX (ligne information TVA à la ligne) $output .=$array[10].';'.($i+1).';;;'.$txtva[$j].';;'; $output .="\n"; $ent1ok="true"; } if(strcmp(strtolower($descarticle[$i]), "eco taxe deee")==0 && strcmp(strtolower($descarticle[$j],"frais de port"))==0 || $ent4ok=="true"){ //$output.="toto4";//$output.="---";$output.=$j; $k=$j+1; //$output .=$i; $pnht[$j]= $puht[$j] * (1-($remise_percent[$j]/100)); //DEMAT-LIN (ligne de facturation) $output .=$array[8].';'.($i+1).';'.$tabgtin[$j].';EN;;;;'.$codefournisseur[$j].';;;'.$libelle[$j].';;;;;'.$qty[$k].';'.$qtyliv[$i].';;;;PCE;'.$totalht[$k].';'.$pnht[$j].';'.$puht[$j].';;;;;;;;;'.$numcmd.';;'.$datecmd.';'.$numbonliv.';'.($i+1).';'.$datebonliv.';'.$numavex.';'.($i+1).';'.$dateavex.';;'.$totalttc[$k].';;;;;;;PIECES'.$pieces_produit_table[$i].''; $output .="\n"; //DEMAT-CTL(ligne de commentaires) $output .=$array[9].';'.($i+1).';;;;;;'; $output .="\n"; //DEMAT-TAX (ligne information TVA à la ligne) $output .=$array[10].';'.($i+1).';;;'.$txtva[$j].';;'; $output .="\n"; $ent4ok="true"; } else if ($ent2ok=="true"){ //$output.="toto5"; $ent2ok="false"; $ent3ok="true"; //$output .=$i; } } else if($ent1ok=="true"){ //$output.="toto6"; //$output .=$i; $j++; //$output.=$j; $pnht[$j]= $puht[$j] * (1-($remise_percent[$j]/100)); //DEMAT-LIN (ligne de facturation) $output .=$array[8].';'.($i+1).';'.$tabgtin[$j].';EN;;;;'.$codefournisseur[$j].';;;'.$libelle[$j].';;;;;'.$qty[$j].';'.$qtyliv[$i].';;;;PCE;'.$totalht[$j].';'.$pnht[$j].';'.$puht[$j].';;;;;;;;;'.$numcmd.';;'.$datecmd.';'.$numbonliv.';'.($i+1).';'.$datebonliv.';'.$numavex.';'.($i+1).';'.$dateavex.';;'.$totalttc[$j].';;;;;;;PIECES'.$pieces_produit_table[$i].''; $output .="\n"; //DEMAT-CTL(ligne de commentaires) $output .=$array[9].';'.($i+1).';;;;;;'; $output .="\n"; //DEMAT-TAX (ligne information TVA à la ligne) $output .=$array[10].';'.($i+1).';;;'.$txtva[$j].';;'; $output .="\n"; } else if($ent3ok=="true"){ //$output .=$i; //$output.="toto7"; $j++; $pnht[$i]= $puht[$i] * (1-($remise_percent[$i]/100)); //DEMAT-LIN (ligne de facturation) $output .=$array[8].';'.($i+1).';'.$tabgtin[$i].';EN;;;;'.$codefournisseur[$i].';;;'.$libelle[$i].';;;;;'.$qty[$j].';'.$qtyliv[$i].';;;;PCE;'.$totalht[$j].';'.$pnht[$i].';'.$puht[$i].';;;;;;;;;'.$numcmd.';;'.$datecmd.';'.$numbonliv.';'.($i+1).';'.$datebonliv.';'.$numavex.';'.($i+1).';'.$dateavex.';;'.$totalttc[$j].';;;;;;;PIECES'.$pieces_produit_table[$i].''; $output .="\n"; //DEMAT-CTL(ligne de commentaires) $output .=$array[9].';'.($i+1).';;;;;;'; $output .="\n"; //DEMAT-TAX (ligne information TVA à la ligne) $output .=$array[10].';'.($i+1).';;;'.$txtva[$i].';;'; $output .="\n"; } else{ //$output .=$i; //$output.="toto8"; $ent1ok="false"; $pnht[$i]= $puht[$i] * (1-($remise_percent[$i]/100)); //DEMAT-LIN (ligne de facturation) $output .=$array[8].';'.($i+1).';'.$tabgtin[$i].';EN;;;;'.$codefournisseur[$i].';;;'.str_replace("'","",$libelle[$i]).';;;;;'.$qty[$i].';'.$qtyliv[$i].';;;;PCE;'.$totalht[$i].';'.$pnht[$i].';'.$puht[$i].';;;;;;;;;'.$numcmd.';;'.$datecmd.';'.$numbonliv.';'.($i+1).';'.$datebonliv.';'.$numavex.';'.($i+1).';'.$dateavex.';;'.$totalttc[$i].';;;;;;;PIECES'.$pieces_produit_table[$i].';RED'.$remise_percent[$i].''; $output .="\n"; //DEMAT-CTL(ligne de commentaires) $output .=$array[9].';'.($i+1).';;;;;;'; $output .="\n"; //DEMAT-TAX (ligne information TVA à la ligne) $output .=$array[10].';'.($i+1).';;;'.$txtva[$i].';;'; $output .="\n"; } //echo $tab_redchlgn[$i]; if($tab_redchlgn[$i]==1){ //DEMAT-DED (ligne remises & charges à la ligne)) //$remise[$i]=$puht[$i]*$qty[$i] - $totalht[$i]; $remise[$i]=$puht[$i]*$remise_percent[$i]/100; //Les montants de réductions ou de charges indiqués à la ligne sont toujours des valeurs unitaires (p85) $output .=$array[11].';'.($i+1).';A;;;2;RAA;RISTOURNE;;204;'.$remise[$i].';'.$remise_percent[$i].';;'; $output .="\n"; } //$output.= $ecotaxdee[$i]; if($ecotaxdee[$i]==1){ //DEMAT-DED (ligne remises & charges à la ligne)) //Les montants de réductions ou de charges indiqués à la ligne sont toujours des valeurs unitaires (p85) $charge[$i]=$qty[$i]*$montantecotaxdeee[$i]; $output .=$array[11].';'.($i+1).';C;;3001000002459;2;TX;TAXE DEEE;;23;'.$charge[$i].';;20;'; $output .="\n"; $chargeglob = $chargeglob + $charge[$i]; } } if ($chargefraisdeport=="true" ){//Frais de port //$numlignart++; $chargefraisdeport="false"; //$fraisdeport="false"; for ($i=0;$i<$numlignart_notmodified;$i++){ if(strtolower($descarticle[$i])=="frais de port"){ //DEMAT-REM (ligne remises/escompte/charges) $output .=$array[7].';;C;;;2;FC;FRAIS DE PORT;;;'.$totalht[$i].';;'.$tvatxfactdet[$i].';'; $output .="\n"; } } } if($remiseglob=="true"){ //$numlignart++; $remiseglob=="false"; for ($i=0;$i<$numlignart_notmodified;$i++){ if($tab_remiseglob[$i]==1){ $alckey = strtolower($descarticle[$i]); $percremiseglob = -$totalht[$i]*100/(-$totalht[$i] + $total_ht); $percremiseglob = number_format($percremiseglob,2); //DEMAT-REM (ligne remises/escompte/charges) $output .=$array[7].';;A;;;2;'.$arrayforalcseg["$alckey"].';'.$descarticle[$i].';;;'.-$totalht[$i].';'.$percremiseglob.';'.$tvatxfactdet[$i].';'; $output .="\n"; } } } //DEMAT-DEB (ligne declaration echange de bien) $output .=$array[12].';V01.0;;;;'; $output .="\n"; //DEMAT-TTX (ligne pied de facture synthèse TVA) $output .=$array[13].';;;;'.$TVA_taux.';'.$total_ht.';'.$total_tva.';'.$total_ttc.';'; $output .="\n"; if ($chargetaxeparafiscale=="true" ){ $chargetaxeparafiscale="false"; //DEMAT-RRC (ligne pied de facture recap des charges) $output .=$array[14].';;C;3001000002459;2;TX;TAXE DEEE;'.$chargeglob.';20;'; $output .="\n"; } //DEMAT-END (ligne pied de facture montants) if($entite == 11) { $output .=$array[15].';V01.0;;'.$note_public.';'.$total_ht.';'.$total_ttc.';'.$total_tva.';'; $output .="\n"; } else { $output .=$array[15].';V01.0;;'.$facnumber.';'.$total_ht.';'.$total_ttc.';'.$total_tva.';'; $output .="\n"; } //DEMAT-ZZZ (ligne fin d'enveloppe de fichier) $output .=$array[16].';V01.0;;;;;'; $output .="\n"; /* // upload the file if (!file_exists('./exp_invoic_csv/'.$rsocfactPar.'/')) { mkdir('./exp_invoic_csv/'.$rsocfactPar.'/', 0777, true); } $chemin='./exp_invoic_csv/'.$rsocfactPar.'/'; */ $filename = "$datec.$GLNfactA.$facnumber.csv"; //echo "nombre d'erreurs en bas: ".$error."\n"; if(!$error) { $sql="UPDATE $tfact set isExportedEDI='1',date_export_edi=now() WHERE $tfact.rowid='$facid'"; $resql = $db->query($sql); } $chemin=__DIR__ ."/csv_invoice/"; $filename = $rsocfactPar.".".$filename; $myfile = fopen($chemin.$filename, 'w') or die('Cannot open file: '.$my_file); fwrite($myfile, $output); fclose($myfile); file_put_contents($chemin.$filename, $output); @chmod($chemin.$filename,0777); @chown($chemin.$filename,"admin"); @chgrp($chemin.$filename,"administrators"); //header ("Location: facture.php?facid=$facid&set=$set&edi=$error" );//redirection vers page précédente print "1"; exit; /*informations enlevées : -$codePayscmdPar -$codePaysfactA -$montantecotaxdeee -$pieces_produit */ ?>