<?php

ini_set('display_errors', 1);

define("ADMIN", true);
require_once("../../common/lib.php");
require_once("../../common/define.php");
define("TITLE_ELEMENT", 'Liste des Mouvements de Stock');
if(!isset($_SESSION['user'])){
    header("Location: /admin/login.php");
    exit();
}


if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    $id = (int)$_GET['id'];



                            $query_be = "SELECT * FROM `pm_mouvement_stock_pf` WHERE id =".$id;
							$result_be = @$db->query($query_be);

							if ($result_be !== false) {
								$row_be = $result_be->fetch();
								$qte = $row_be['qte'];
								$id_depot = $row_be['id_depot'];
								$id_produits = $row_be['id_produits'];
							}
	$update_source_query = "UPDATE pm_depot_stock_pf SET qte = qte + ".$qte." WHERE id_depot = ".$id_depot." AND id_produits = ".$id_produits;		
	// echo $update_source_query ;	
	@$db->query($update_source_query);

    $query = "UPDATE pm_mouvement_stock_pf SET status = 0 where id=".$id;
	@$db->query($query);

}

header("Location: /admin/stock_pf/");
exit();
?>
