IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

Afficher sans Enregistrer des factures dans phpmyadmin lorsque c'est l'utilisateur qui crée la facture [MySQL]


Sujet :

PHP & Base de données

Mode arborescent

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre à l'essai
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2018
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Juin 2018
    Messages : 5
    Par défaut Afficher sans Enregistrer des factures dans phpmyadmin lorsque c'est l'utilisateur qui crée la facture
    Bonjour,

    voici mon problème, je voudrait que l'utilisateur $idgroup0[0]== 4; puisse se creer des factures sans que cela ne soit enrégistrer dans ma base de donnée. je suis vraiment à mes debuts.


    voici mon code


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    <?php 
     
     
    session_start();
    include("verif_connexion.php");
    include("connectbdd.php");
    include("entete.php");
     
     
     
     
     
    	if ((isset($_POST['datedeb']))&&(isset($_POST['datefin']))&&(isset($_POST['client'])))
    	{
     
    		$datedeb=$_POST['datedeb'];
     
     
    		$datefin=$_POST['datefin'];
     
     
    		$client=$_POST['client'];
    		$idpdv=mysqli_query($con,"SELECT idstore,storecode from store where idstore=$client");
    		$idstore=0;
    		$codepdv='';
    		if ($idpdv)
    		{
    			$idpdv0=mysqli_fetch_array($idpdv);
    			$idstore=$idpdv0['0'];
    			$codepdv=$idpdv0['1'];
    		}
     
    		if ($idstore==0 || $codepdv=='')
    		{
    				echo '<html><head></head><body><script type="text/javascript">'; 
    				echo 'alert("Le client '.$client.' est inexistant.");'; 
     
    				echo 'javascript:history.go(-1);';
    				echo '</script></body></html>';
    				exit;
    		}
     
    		$idfacture=$_GET['idfacture'];
     
     
    		$datedeb1 = explode('/',$datedeb);
     
    		$datedeb2=$datedeb1['2'].$datedeb1['1'].$datedeb1['0'];
     
    		$datefin1 = explode('/',$datefin);
    		$datefin2=$datefin1['2'].$datefin1['1'].$datefin1['0'];
     
    		//on va vérifier si la facture existe
    		$sSQL="SELECT idfacture,nfacture from facture where (deb=$datedeb2 and fin=$datefin2 and store_idstore=$idstore) ";
    		$factureExiste=mysqli_query($con, $sSQL);
     
    		if ($factureExiste && !$idgroup0[0]==4 )
    		{
    			$factureExisteData=mysqli_fetch_array($factureExiste);
    			if (intval($factureExisteData['0'])>0)
    			{
    				$nf=$factureExisteData['1'];
    				echo '<html><head></head><body><script type="text/javascript">';
    				echo 'window.location.href = "rechercherfacture.php?code='.$nf.'";';
    				//echo 'javascript:history.go(-1);';
    				echo '</script></body></html>';
    				exit;
    			}
    			else if($factureExiste && $idgroup0[0]==4) 
    			{
    					$factureExisteData=mysqli_fetch_array($factureExiste);
    				if (intval($factureExisteData['0'])>0)
    				{
    					$nf=$factureExisteData['1'];
    					echo '<html><head></head><body><script type="text/javascript">';
    					echo 'window.location.href = "rechercherfacture.php?";';
    					//echo 'javascript:history.go(-1);';
    					echo '</script></body></html>';
    					exit;
     
    				}
    			}	
    		}
    		$result = mysqli_query($con,'SELECT CURRENT_DATE');
    		$data=mysqli_fetch_array($result);
    		$datefacturation= $data[0];
    		$datefac1 = explode('-',$datefacturation);
    		$datefac2=$datefac1['0'].$datefac1['1'].$datefac1['2'];
     
    		$annee2=date('y',strtotime($datefac2));
     
     
    		$infokiosque=mysqli_query($con,"SELECT company,address1,address2,address3,postcode,city,manager_name,manager_fname,civility.civility FROM store,civility where storecode='$codepdv' and civility.idcivility=store.civility_idcivility"); 
    			if ($infokiosque)
    			{
     
     
    				$infokiosque0=mysqli_fetch_array($infokiosque);
    				$dernierefacture=mysqli_query($con,"SELECT idnfacture, nfacture,date from nfacture order by idnfacture DESC limit 1 ");
     
    				if($dernierefacture)
    				{
    						$dernierefacture0=mysqli_fetch_array($dernierefacture);
    						$detaildate=explode('-',$dernierefacture0['2']);
    						$mois=$detaildate['1'];
     
    						$annee=$detaildate['0'];
     
    						if($datefac1['1']==$mois)
    						{
    							$nfacture=$dernierefacture0['1']+1;
    						}
    						else { $nfacture=1; }
     
    						if ($nfacture<10) 
    							{	
    								$nfacture2='F'.$annee2.$datefac1['1'].'00'.$nfacture;
    							}
    								else 
    								{
    									if ($nfacture<100) 
    									{	
    										$nfacture2='F'.$annee2.$datefac1['1'].'0'.$nfacture;
    									}
    									else 
    									{	
    										$nfacture2='F'.$annee2.$datefac1['1'].$nfacture;
    									}
    								}
    					if ($idgroup0[0]==4){
    							$generenfacture=mysqli_query($con,"insert into nfacture (nfacture,date, nfacture2) values ($nfacture,$datefac2, '$nfacture2')");
    							$today=getdate();
     
    					if ($generenfacture)
     
    						{
     
     
    						$idpdv=mysqli_query($con,"SELECT idstore from store where storecode='$codepdv'");
    						if ($idpdv)
    						{
    							$idpdv0=mysqli_fetch_array($idpdv);
     
     
     
    							$nvellefacture=mysqli_query($con,"INSERT INTO facture (nfacture,deb,fin,etat,store_idstore) values ('$nfacture2',$datedeb2,$datefin2,0,$idpdv0[0])");
    							if($nvellefacture)
    							{
    								$time=$today['hours'].':'.$today['minutes'].':'.$today['seconds'];
     
    								$log=$_SESSION['log'];
     
    								$historique=mysqli_query($con,"insert into modification(user,date,time,query) values ('$log',current_date(),'$time','Création de la facture ".$nfacture2." ')");
     
    								$contact=mysqli_query($con,"select civility.civility,manager_fname,manager_name,company,address1,address2,address3,postcode,city from store,civility where civility.idcivility=store.civility_idcivility and storecode='$codepdv'");
    								$contact0=mysqli_fetch_array($contact);
     
     
     
    								$jourj=date("d-m-Y");
    								$jours=explode('-',$jourj);
     
    								$reqFacture=mysqli_query($con," SELECT idfacture from facture where nfacture='$nfacture2'");
    								$reqFacture0=mysqli_fetch_array($reqFacture);
    								$monidfacture=$reqFacture0[0];
     
    								$txtSQL="INSERT INTO facturecorps (idfacture, nfacture, codearticle,libarticle,qte,prix,qteinvendu) 
    										SELECT $monidfacture AS idfacture, '$nfacture2' AS nfacture
    											, `newspaperbo_newspapercode` AS codearticle
    											, MAX(`newspaperbo`.`description`)  AS libarticle
    											, SUM(`quantityprint`) AS qte
    											, MAX(`salesprice`) AS prix
    											, SUM(`nbinvendu`) AS qteinvendu
    										   
    										FROM
    											`order`  
    											LEFT JOIN `newspaperbo` 
    												ON (`order`.`newspaperbo_newspapercode` = `newspaperbo`.`newspapercode`)
    										WHERE (`publicationdate` >=$datedeb2
    											AND `publicationdate` <=$datefin2
    											AND `store_storecode` ='$codepdv')
    											 GROUP BY `newspaperbo_newspapercode`";
     
    							$reqorder=mysqli_query($con,$txtSQL);
    								if($reqorder)
    								{
     
     
     
    								header('location:rechercherfacture.php?code='.$nfacture2.'&nf=1');
     
    								}
    							}		
    						}
    					}
     
    					}
    				else{
    							$generenfacture=mysqli_query($con,"insert into nfacture (nfacture,date, nfacture2) values ($nfacture,$datefac2, '$nfacture2')");
    							$today=getdate();
     
    					if ($generenfacture)
     
    						{
     
     
    						$idpdv=mysqli_query($con,"SELECT idstore from store where storecode='$codepdv'");
    						if ($idpdv)
    						{
    							$idpdv0=mysqli_fetch_array($idpdv);
     
     
     
    							$nvellefacture=mysqli_query($con,"INSERT INTO facture (nfacture,deb,fin,etat,store_idstore) values ('$nfacture2',$datedeb2,$datefin2,0,$idpdv0[0])");
    							if($nvellefacture)
    							{
    								$time=$today['hours'].':'.$today['minutes'].':'.$today['seconds'];
     
    								$log=$_SESSION['log'];
     
    								$historique=mysqli_query($con,"insert into modification(user,date,time,query) values ('$log',current_date(),'$time','Création de la facture ".$nfacture2." ')");
     
    								$contact=mysqli_query($con,"select civility.civility,manager_fname,manager_name,company,address1,address2,address3,postcode,city from store,civility where civility.idcivility=store.civility_idcivility and storecode='$codepdv'");
    								$contact0=mysqli_fetch_array($contact);
     
     
     
    								$jourj=date("d-m-Y");
    								$jours=explode('-',$jourj);
     
    								$reqFacture=mysqli_query($con," SELECT idfacture from facture where nfacture='$nfacture2'");
    								$reqFacture0=mysqli_fetch_array($reqFacture);
    								$monidfacture=$reqFacture0[0];
     
     
    								$txtSQL="INSERT INTO facturecorps (idfacture, nfacture, codearticle,libarticle,qte,prix,qteinvendu) 
    										SELECT $monidfacture AS idfacture, '$nfacture2' AS nfacture
    											, `newspaperbo_newspapercode` AS codearticle
    											, MAX(`newspaperbo`.`description`)  AS libarticle
    											, SUM(`quantityprint`) AS qte
    											, MAX(`salesprice`) AS prix
    											, SUM(`nbinvendu`) AS qteinvendu
    										   
    										FROM
    											`order`  LEFT JOIN `newspaperbo` 
    												ON (`order`.`newspaperbo_newspapercode` = `newspaperbo`.`newspapercode`)
    										WHERE (`publicationdate` >=$datedeb2
    											AND `publicationdate` <=$datefin2
    											AND `store_storecode` ='$codepdv')
    											 GROUP BY `newspaperbo_newspapercode`";
     
    							$reqorder=mysqli_query($con,$txtSQL);
    								if($reqorder)
    								{
     
     
     
    								header('location:rechercherfacture.php?code='.$nfacture2.'&nf=1');
     
    								}
     
    							}
    						}
    					}
    				}
     
     
    				}
    			}
     
    	}
     
    ?>
    Fichiers attachés Fichiers attachés

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Dojo] Choix des colonnes a afficher avec enregistrement du choix dans une dataGrid
    Par devkaty dans le forum Bibliothèques & Frameworks
    Réponses: 9
    Dernier message: 13/07/2009, 13h34
  2. probleme d'enregistrement des accents dans la BDD
    Par Invité dans le forum Installation
    Réponses: 1
    Dernier message: 09/07/2006, 21h07
  3. [VB6]enregistrer des données dans un fichier
    Par tchinette42 dans le forum VB 6 et antérieur
    Réponses: 6
    Dernier message: 19/04/2006, 18h55
  4. [VB.NET] Enregistrement des propriétés dans l'éditeur.
    Par leSeb dans le forum Windows Forms
    Réponses: 15
    Dernier message: 26/01/2006, 11h33
  5. afficher la signature des opérations dans XDE
    Par ChristopheH dans le forum Rational
    Réponses: 1
    Dernier message: 24/05/2004, 15h41

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo