Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('display_errors', 1);
- ini_set('display_startup_errors', 1);
- error_reporting(E_ALL);
- include("db.php");
- // $docnr = $_POST['docnr'];
- // $action = $_POST['action'];
- // $docnr = $_POST['docnr'];
- // $action = $_POST['action'];
- $docnr = 6438403;
- $action = 'receptie';
- // $data = date("Y-m-d H:i:s", strtotime('+1 hour'));
- if($action && $action == 'receptie')
- {
- $details = array();
- $defect = array();
- $tsql = "select
- w.id,
- w.series,
- w.lengthnet,
- w.diameternet,
- w.cubagenet,
- ISNULL(w.loadingpoint,'') as loadingpoint,
- ISNULL(n.cmrnumber,'') as cmrnumber,
- ISNULL(n.trailnumber,'') as trailnumber,
- ISNULL(n.carnumber,'') as carnumber,
- ISNULL(t.name,'') as transporter
- from wood w
- left join notice n
- on w.idnotice = n.id
- left join Transporter t
- on t.id = n.idtransporter
- where n.docnr = '$docnr'";
- $stmt = sqlsrv_query($conn, $tsql);
- $row=array();
- while ($row = sqlsrv_fetch_array($stmt)) {
- $series = $row['series'];
- $id = $row['id'];
- $tsql1 = "select
- ISNULL(DefectType.alias,'') as alias,
- ISNULL(Defect.length,'') as length
- from Defect
- inner join DefectType
- on Defect.iddefecttype = DefectType.id
- where idwood = $id";
- // echo $tsql1."</br>";
- $stmt1 = sqlsrv_query($conn, $tsql1);
- $row1[] = sqlsrv_fetch_array($stmt1);
- sqlsrv_free_stmt($stmt1);
- }
- $defect = array();
- if(!empty($series))
- {
- // var_dump($row1);
- // die();
- //
- if(!empty($row1)){
- // echo "Prima data";
- // $row1= array($row1);
- // var_dump($row1);
- // die();
- foreach ($row1 as $key=> $value) {
- $defect[]=array('alias' => $row1[$key]['alias'],
- 'length'=>$row1[$key]['length'],
- );
- // array_push($defect, array("alias"=>$row1[$key]['alias'],"length"=>$row1[$key]['length']));
- }
- // var_dump($defect);
- // die();
- }
- array_push($details, array("series"=>$row['series'],"diameternet"=>$row['diameternet'],"lengthnet"=>round($row['lengthnet'],2),"cubagenet"=>round($row['cubagenet'],2), "loadingpoint"=>$row['loadingpoint'],"cmrnumber"=>$row['cmrnumber'],"trailnumber"=>$row['trailnumber'],"transporter"=>round($row['transporter'],2),"defect"=>$defect));
- }
- echo json_encode($details);
- sqlsrv_free_stmt($stmt);
- sqlsrv_close( $conn);
- //WLOG($verificare);
- //WLOG($tsql);
- //FUNCTION WLOG($MESSAGE){
- //
- // $D=DATE("Y-M-D H:I:S");
- // FILE_PUT_CONTENTS("RECEPTIE.TXT", "\N $D ".$MESSAGE, FILE_APPEND);
- //
- //}
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement