AnonSec Team
Server IP : 10.128.40.6  /  Your IP : 216.73.216.233
Web Server : Apache
System : Linux webd006.cluster128.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User : logmcpe ( 111175)
PHP Version : 7.3.33
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/logmcpe/www/TMCPRO/pages/UI/../

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/logmcpe/www/TMCPRO/pages/UI/../fcdocument.php
<?php
// include 'includes/config_tmcpro2.php' ;
include 'includes/config_tmcpro.php' ;
include 'includes/stable_functions_tmcpro.php' ;
$pagemenu = basename($_SERVER["PHP_SELF"]) ;

$agence = 7 ;

 $client =$_SESSION["client_id"] ;
  $client_id=$_SESSION["client_id"] ;
 // $client=$_SESSION["client_id"] ;
 // ini_set('display_errors','on');
// error_reporting(E_ALL);

 // echo "==> $client <br/>" ;

// print_header ();
 include('file_tache.php');

function string2url($chaine) {
 $chaine = trim($chaine);
 $chaine = strtr($chaine, "A?A???а?в?????O?????ф???EEEEийклCз??II??опU?UUщ?ыь???","aaaaaaaaaaaaooooooooooooeeeeeeeecciiiiiiiiuuuuuuuuynn");
 $chaine = strtr($chaine,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz");
 $chaine = preg_replace('#([^.a-z0-9]+)#i', '-', $chaine);
        $chaine = preg_replace('#-{2,}#','',$chaine);
        $chaine = preg_replace('#-$#','',$chaine);
        $chaine = preg_replace('#^-#','',$chaine);
 return $chaine;
}


	if (!is_dir("documents"))
	{
		mkdir("documents", 0755) ;
		chmod("documents", 0755) ;
	}
		if (!is_dir("documents/clients"))
	{
		mkdir("documents/clients", 0755) ;
		chmod("documents/clients", 0755) ;
	}
		if (!is_dir("documents/intervenants"))
	{
		mkdir("documents/intervenants", 0755) ;
		chmod("documents/intervenants", 0755) ;
	}





$nomrep="documents/clients";
// echo "vvv <br/>" ;
if(isset($_GET['action']) && isset($_GET['id'])&& $_GET['action']=='sup')
{
	// echo "vvvKKKK <br/>" ;
	// exit();
$id=$_GET['id'];
$qa1 = dbi_query("DELETE FROM document_client WHERE document_id = ".$id) ;

$a1=dbi_fetch_row($qa1);
	header('Location:fcdocument.php?msg=Document bien supprimé&color=success');

}

// supprimer les document de la table document_tache  Tache

if(isset($_GET['action']) && isset($_GET['id'])&& $_GET['action']=='sup_doc_tach')
{
	// echo "vvvKKKK <br/>" ;
	// exit();
$id=$_GET['id'];
$qa1 = dbi_query("DELETE FROM document_tache WHERE `document_tache`.`doc_id` = ".$id) ;

$a1=dbi_fetch_row($qa1);
	header('Location:fcdocument.php?msg=Document bien supprimé&color=success');

}






// if(!empty($_POST['Modifier']))
// {

// }


if($_POST["Modifier"]== "Modifier"){
	 // echo "aa <br/>" ;
  if (!file_exists($_FILES['file']['tmp_name']) || !is_uploaded_file($_FILES['file']['tmp_name']))
  {


	  	// echo "<pre>" ;
	// print_r($_POST) ;
	// echo "<pre>" ;

	// exit() ;



  $document_id=$_POST['document_id'] ;
						$document_nom=$_POST['document_nom'] ;





	// dbi_query("INSERT INTO document_client (

						// document_nom,
						// client_id,
						// document_visibilite,
						// date_document,
						// document_emplacement )

						// VALUES (

						// '$document_nom',
						// '$client_id',
						// '$document_visibilite',
						// '$date_document',
						// '$target_file'

					    // )") ;



$document_prive=$_POST['document_prive'] ;
						dbi_query("

						UPDATE document_client SET
						document_nom = '$document_nom',
						document_prive = '$document_prive',

                        client_id = '$client_id'
						WHERE document_id = '$document_id'

					    ") ;
						header('Location:fcdocument.php?msg=Document bien Modifié&color=success');
  }
  else
  {

	  				  				  $target_dir = "documents/clients/";
									  $document_id=$_POST['document_id'] ;

  $target_file = $target_dir."".$document_id."". basename(addslashes($_FILES["file"]["name"]));
  $uploadOk = 1;
  $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));


				 move_uploaded_file($_FILES["file"]["tmp_name"], $target_file) ;

				 // header("location: salarie_document.php?msg=Course added&color=success");


						$document_nom= addslashes($_POST['document_nom']) ;
						$document_visibilite=$_POST['document_visibilite'] ;
						$document_prive=$_POST['document_prive'] ;







						dbi_query("

						UPDATE document_client SET
						document_nom = '$document_nom',
						document_emplacement = '$target_file' ,
						document_prive = '$document_prive' ,

                          client_id = '$client_id'
						WHERE document_id = '$document_id'

					    ") ;
						header('Location:fcdocument.php?msg=Document bien Modifié&color=success');
						// header("location: course.php");




  }
}




// modifier les documents de la tache



if($_POST["Modifier"]== "Modifier_tache"){
	 // echo "aa <br/>" ;
  if (!file_exists($_FILES['file']['tmp_name']) || !is_uploaded_file($_FILES['file']['tmp_name']))
  {


	  	// echo "<pre>" ;
	// print_r($_POST) ;
	// echo "<pre>" ;

	// exit() ;



  $document_id=$_POST['doc_id'] ;
						$document_nom=$_POST['document_nom'] ;





	// dbi_query("INSERT INTO document_client (

						// document_nom,
						// client_id,
						// document_visibilite,
						// date_document,
						// document_emplacement )

						// VALUES (

						// '$document_nom',
						// '$client_id',
						// '$document_visibilite',
						// '$date_document',
						// '$target_file'

					    // )") ;




						dbi_query("

						UPDATE document_tache SET
						document_nom = '$document_nom',


                        client_id = '$client_id'
						WHERE doc_id = '$document_id'

					    ") ;
						header('Location:fcdocument.php?msg=Document bien Modifié&color=success');
  }
  else
  {

	  				  				  $target_dir = "documents/tache/";
									  $document_id=$_POST['doc_id'] ;

  $target_file = $target_dir."".$document_id."". basename(addslashes($_FILES["file"]["name"]));
  $uploadOk = 1;
  $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));


				 move_uploaded_file($_FILES["file"]["tmp_name"], $target_file) ;

				 // header("location: salarie_document.php?msg=Course added&color=success");


						$document_nom= addslashes($_POST['document_nom']) ;
						// $document_visibilite=$_POST['document_visibilite'] ;







						dbi_query("

						UPDATE document_tache SET
						document_nom = '$document_nom',
						document_emplacement = '$target_file' ,

                          client_id = '$client_id'
						WHERE doc_id = '$document_id'

					    ") ;
						header('Location:fcdocument.php?msg=Document bien Modifié&color=success');
						// header("location: course.php");




  }
}













if((!empty($_FILES)) and (empty($_POST['Modifier'])))
{





	// echo "<pre>" ;
	// print_r($_FILES) ;
	// echo "<pre>" ;


	// echo "<pre>" ;
	// print_r($_POST) ;
	// echo "<pre>" ;


	// exit() ;

	       list($document_id)=  dbi_fetch_row(dbi_query( "SELECT max(document_id) FROM `document_client`")) ;
		  $document_id= $document_id + 1 ;
				  $target_dir = "documents/clients/";
				  $date_document = date('Ymd');
				   // str_replace("'", "", $chaineAvecApostrophes);
				   
				     $filename = $_FILES["file"]["name"];
$filename = str_replace("'", "_", $filename);
$target_file = $target_dir . $document_id . basename($filename);


  // $target_file = $target_dir."".$document_id."". basename(str_replace("'", "", $_FILES["file"]["name"]));
  $uploadOk = 1;
  $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));


				 move_uploaded_file($_FILES["file"]["tmp_name"], $target_file) ;

				 // header("location: salarie_document.php?msg=Course added&color=success");

						$document_nom=str_replace("'", "", $_POST['document_nom']) ;
						$document_visibilite=$_POST['document_visibilite'] ;
						$document_prive=$_POST['document_prive'] ;




						dbi_query("INSERT INTO document_client (

						document_nom,
						client_id,
						document_visibilite,
						date_document,
						document_prive,
						document_emplacement )

						VALUES (

						'$document_nom',
						'$client_id',
						'$document_visibilite',
						'$date_document',
						'$document_prive',
						'$target_file'

					    )") ;
						header('Location:fcdocument.php?msg=Document bien ajouté&color=success');



// $qa1 = dbi_query("SELECT client_nom,client_data FROM ".TABLE_CLIENT." WHERE  client_id=$client ") ;
// $a1=dbi_fetch_row($qa1);
// $data = unserialize($a1['client_data']);

// $nbre_data=count($data);
// $nb_min = 1;
// $nb_max = 10000;
// $nombre = mt_rand($nb_min,$nb_max);
// $client_nom=$a1['client_nom'];
// $desc="";
// if(!empty($_POST['desc']))
// $desc=$_POST['desc'];



// $date_doc = date('Ymd');
// $extension = strrchr($_FILES['doc']['name'], '.');

// $nom_doc=addslashes('client-'.$agence.'-'.$client_nom.''.$nombre.''.$extension.'');

// $nom_doc=string2url($nom_doc);

// if(empty($a1['client_data']))
// $client_data=array(array($nom_doc,$date_doc,$desc));
// else {
// $client_data=$data;
// array_push( $client_data,array($nom_doc,$date_doc,$desc));
// }

// if(move_uploaded_file($_FILES['doc']['tmp_name'] , "$nomrep/".$nom_doc.''))
// dbi_query("UPDATE ".TABLE_CLIENT." SET client_data='".addslashes(serialize($client_data))."' WHERE  client_id=$client ") ;
// else $erreur=true	;

	}



$q= dbi_fetch_row(dbi_query("SELECT * FROM client where client_id = ".$client_id)) ;

	?>





<!DOCTYPE html>
<html>


<head>

			<?php include('header.php'); ?>
			  <!-- 
	  <script type="text/javascript" src="plugins/selectize/selectize.js"></script>
	<link rel="stylesheet" type="text/css" href="plugins/selectize/selectize.css" />
	<script type="text/javascript" src="plugins/selectize/selectize.min.js"></script>
	<link rel="stylesheet" type="text/css" href="plugins/selectize/selectize.default.css" />
	<link rel="stylesheet" href="../../plugins/summernote/summernote-bs4.css">


<script src="plugins/jQuery/jquery-2.2.3.min.js"></script>

<script src="bootstrap/js/bootstrap.min.js"></script>

<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables/dataTables.bootstrap.min.js"></script>

<script src="plugins/slimScroll/jquery.slimscroll.min.js"></script>
-->
  <style type="text/css">
  .modal-backdrop {
    /* bug fix - no overlay */
    display: none;
}
</style>

			</head>


<body class="hold-transition sidebar-mini">
												<!-- Site wrapper -->
<div class="wrapper">

		  <nav class="main-header navbar navbar-expand navbar-white navbar-light">
		 <!-- Menu extensible -->
			<ul class="navbar-nav">
			  <li class="nav-item">
				<a class="nav-link" data-widget="pushmenu" href="#"><i class="fas fa-bars"></i></a>
			  </li>

		<!-- liens TOP MENU GAUCHE-->

			  <li>
			  <button  href="#myModal"  id="custId" data-toggle="modal" type="button" class="btn btn-primary" ><i class="fas fa-plus"></i><?php echo strtoupper (" Document") ; ?> </button></h3>
			  </li>
			  &nbsp <li> <h3><a href="#myModal_tache_all"  id="custId" data-toggle="modal" >   <button type="button"  class="btn btn-primary" > <i class="fas fa-plus"></i> TACHE</button> </a></h3></li>




			</ul>

		 <!-- liens TOP MENU DROITE -->
			<ul class="navbar-nav ml-auto">
			 <!-- Placer ici l'élément à positionner à droite du TOP MENU -->
			</ul>

		  </nav>  <!-- fin du TOP MENU -->



<!-- BARRE DE NAVIGATION -->

 <!-- Couleur et caracteristiques de la barre de navigation-->



 <?php include('menu.php'); ?>

   <div  class="modal fade" id="myModal" role="dialog" class="modal fade task-modal-single in" tabindex="-1"  aria-labelledby="myLargeModalLabel" >
  <div class="modal-dialog modal-lg">
    <div class="modal-content data">
		<div id="fetch" ></div>


        </div>
    </div>
</div>

<div  class="modal fade" id="myModal_tache_all" role="dialog" class="modal fade task-modal-single in" tabindex="-1"  aria-labelledby="myLargeModalLabel" >
  <div class="modal-dialog modal-lg">
    <div class="modal-content data">
		<div id="fetch_tache_all" ></div>


        </div>
    </div>
</div>
 <!-- Ne pas toucher au dessus / fin de la BARRE DE NAVIGATION-->

 <!-- DEMARRAGE DE LA PAGE PRINCIPALE -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0 text-dark"></h1>
          </div><!-- /.col -->
          <div class="col-sm-6">

          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->

    <!-- PAGE PRINCIPALE -->
    <div class="content">
      <div class="container-fluid">

        <?php include('widget_client_haut.php'); ?>
        </div>
        </div>



        <div class="col-lg-12">
      <!-- CARD DE DROITE-->
           <div class="card card-secondary">

             <?php include('menu_client_haut.php'); ?>





					<div class="card">

						  <!-- /.card-header -->
						<div class="card-body">
						<section class="content">

												   					  		  <?php
			      if(isset($_GET["msg"])){
        ?>
        <div class="alert alert-<?php echo $_GET["color"]; ?>  alert-dismissible col-12" role="alert">
          <strong><?php echo $_GET["color"].': '; ?></strong><?php echo $_GET["msg"]; ?>.
          <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>
        <?php
        }
       ?>


<?php

if(!empty($_GET['document_id']))
{
	// echo " je suis la pour modifié <br/>" ;
	$qa = dbi_query("SELECT * FROM document_client WHERE   document_id  = ".$_GET['document_id']) ;
	    $ddocum= dbi_fetch_row($qa) ;

		$document_emplacement = $ddocum['document_emplacement'];
		$document_nom  = $ddocum['document_nom'] ;
		$document_prive = $ddocum['document_prive'] ;


	?>
	<form action="" enctype="multipart/form-data"  method="POST">

	<div class="form-row">


          <div class="form-group col-md-6">
       <label for="inputAddresse">Nom du Document</label>
    <input type="text" class="form-control"  name="document_nom"   value=" <?php echo $document_nom ;?>" placeholder="Nom du document">
  </div>





				  	<div class="form-group col-md-5">
                    <label for="exampleInputFile">T&#233;l&#233;charger <a target="_blank" href="<?php echo $document_emplacement; ?>">(voir ancienne fichier)</a><br> </label>
                    <div class="input-group">
                      <div class="custom-file">
					  <input type="hidden" value="<?php echo $_GET['document_id']; ?>" name="document_id">

                  <input type="hidden" value="<?php echo $document_emplacement; ?>" name="old-file" id="old-file">
                        <input type="file" class="custom-file-input" name="file"  >

                        <label class="custom-file-label" for="exampleInputFile">Choisir....</label>
                      </div>

					   <div class="input-group-append">
                        <span class="input-group-text" id="">Upload</span>
                      </div>

                    </div>
                  </div>
				  
											<div class="col-sm-1">
												<div class="form-row">
													<label>Privé </label>
													   <input type="checkbox" class="form-control"  name="document_prive" value="1" <?php echo ($document_prive == 1) ? 'checked' : ''; ?>>	
													</div> 	
											</div>











  </div>

    <button type="submit" name="Modifier"  value="Modifier"  class="btn btn-primary">Modifier</button>
  </form>

  <?
}



if(!empty($_GET['doc_id']))
{
	// echo " je suis la pour modifié <br/>" ;
	$qa = dbi_query("SELECT * FROM `document_tache` WHERE `doc_id` =  ".$_GET['doc_id']) ;
	    $ddocum= dbi_fetch_row($qa) ;

		$document_emplacement = $ddocum['document_emplacement'];
		$document_nom  = $ddocum['document_nom'] ;


	?>
	<form action="" enctype="multipart/form-data"  method="POST">

	<div class="form-row">


          <div class="form-group col-md-6">
       <label for="inputAddresse">Nom du Document</label>
    <input type="text" class="form-control"  name="document_nom"   value=" <?php echo $document_nom ;?>" placeholder="Nom du document">
  </div>





				  	<div class="form-group col-md-6">
                    <label for="exampleInputFile">T&#233;l&#233;charger <a target="_blank" href="<?php echo $document_emplacement; ?>">(voir ancienne fichier)</a><br> </label>
                    <div class="input-group">
                      <div class="custom-file">
					  <input type="hidden" value="<?php echo $_GET['doc_id']; ?>" name="doc_id">

                  <input type="hidden" value="<?php echo $document_emplacement; ?>" name="old-file" id="old-file">
                        <input type="file" class="custom-file-input" name="file"  >

                        <label class="custom-file-label" for="exampleInputFile">Choisir....</label>
                      </div>

					   <div class="input-group-append">
                        <span class="input-group-text" id="">Upload</span>
                      </div>

                    </div>
                  </div>











  </div>

    <button type="submit" name="Modifier"  value="Modifier_tache"  class="btn btn-primary">Modifier</button>
  </form>

  <?
}


// 🔹 Une seule requête UNION pour fusionner les deux tables et trier par date décroissante
$sql = "
SELECT 
    document_id AS id, 
    document_nom, 
    date_document AS date_doc, 
    document_emplacement, 
    'client' AS source
FROM document_client
WHERE client_id = $client

UNION ALL

SELECT 
    doc_id AS id, 
    document_nom, 
    date_doc, 
    document_emplacement, 
    'tache' AS source
FROM document_tache
WHERE client_id = $client

ORDER BY date_doc DESC
";

$qa = dbi_query($sql);
?>

<br clear="all" />

<table class="table table-hover">
    <thead>
        <tr>
            <th>Description</th>
            <th style="text-align:center;">Date</th>
            <th style="text-align:center;">Actions</th>
        </tr>
    </thead>
    <tbody>
        <?php
        while ($docc = dbi_fetch_row($qa)) {
            $nomrepp = $docc['document_emplacement'];
        ?>
            <tr>
                <td><?= $docc['document_nom'] ?></td>
                <td style="text-align:center;"><?= int2date($docc['date_doc']) ?></td>
                <td align="center" nowrap>
                    <a class="btn btn-primary btn-sm" href="<?= $nomrepp ?>" target="_blank">
                        <i class="fas fa-file"></i> Consulter
                    </a>

                    <?php if ($docc['source'] == 'client') { ?>
                        <a class="btn btn-info btn-sm" href="fcdocument.php?document_id=<?= $docc['id'] ?>">
                            <i class="fas fa-pencil-alt"></i> Éditer
                        </a>
                        <a class="btn btn-danger btn-sm" href="fcdocument.php?doc=cl&action=sup&id=<?= $docc['id'] ?>" onclick="return confirm('Voulez-vous vraiment supprimer ce document ?');">
                            <i class="fas fa-trash"></i> Supprimer
                        </a>
                    <?php } else { ?>
                        <a class="btn btn-info btn-sm" href="fcdocument.php?doc_id=<?= $docc['id'] ?>">
                            <i class="fas fa-pencil-alt"></i> Éditer
                        </a>
                        <a class="btn btn-danger btn-sm" href="fcdocument.php?doc=cl&action=sup_doc_tach&id=<?= $docc['id'] ?>" onclick="return confirm('Voulez-vous vraiment supprimer ce document ?');">
                            <i class="fas fa-trash"></i> Supprimer
                        </a>
                    <?php } ?>
                </td>
            </tr>
        <?php
        }
        ?>
    </tbody>
</table>



						</div>
					</div>
				 </div>
			</div>


              </div>
            </div>
          </div>
          <!-- /.col-md-6 -->
        </div>
        <!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

  <!-- Control Sidebar -->
  <aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->
    <div class="p-3">
      <h5>Title</h5>
      <p>Sidebar content</p>
    </div>
  </aside>
  <!-- /.control-sidebar -->

			<?php include('footerr.php'); ?>

  <!-- Control Sidebar -->
  <aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->
  </aside>
  <!-- /.control-sidebar -->
</div>
<!-- ./wrapper -->

<!-- jQuery -->




<script type="text/javascript">
$(document).ready(function(){
    $('#myModal_tache_all').on('show.bs.modal', function (e) {
        var rowid = $(e.relatedTarget).data('id');
        $.ajax({
            type : 'post',
            url : 'tache_ajax_nv_all.php', //Here you will fetch records
            data :  'rowid='+ rowid, //Pass $id
            success : function(data){
            $('#fetch_tache_all').html(data);//Show fetched data from database
            }
        });
     });
});


</script>
<script>
  $(function () {
    // Summernote
    $('.textarea').summernote()
  }) ;



  $(document).ready(function(){
    $('#myModal').on('show.bs.modal', function (e) {
        var rowid = $(e.relatedTarget).data('id');
        $.ajax({
            type : 'post',
            url : 'ajaxAjoutDocument.php', //Here you will fetch records
            data :  'rowid='+ rowid, //Pass $id
            success : function(data){
            $('#fetch').html(data);//Show fetched data from database
            }
        });
     });
});

</script>
</body>
</html>

AnonSec - 2021