<?php

	function getAllSOWithSA(){
		global $db;
		
		$company_id = $_SESSION['company_id'];
		$db->bind("company_id",$company_id);
		
		$orderselections = $db->query("SELECT * FROM shipping_orders where forwarder_id = :company_id and (so_id in (select so_id from shipment_arrangement_items where 1) and so_id not in (select so_id from custom_declarations where 1))");
		$table = "";
		
		foreach ($orderselections as $key => $orderselection){
			$table .= "<option value=".$orderselection['so_id'].">" . $orderselection['marking_no'] . "</option>";
		}
		return $table;
	}
	
	function getCDData($so_id, $data){
		global $db;
	
		$db->bind('so_id', $so_id);
		$custom_declarations = $db->query("SELECT * FROM custom_declarations WHERE so_id = :so_id");
		
		return (count($custom_declarations) > 0 ? $custom_declarations[0][$data] : "");
	}