<?php

if (!empty($_GET['mode'])) {
 $mode = $_GET['mode'];
} else {
 $mode = 2;
}

if (empty($$class->supplier_id) && !empty($_GET['supplier_site_id'])) {
 $supplier_site_i = supplier_site::find_by_id($_GET['supplier_site_id']);
 foreach ($supplier_site_i as $k => $v) {
  $$class_second->$k = $v;
 }
 $$class->supplier_id = $$class_second->supplier_id;
 $$class->findBy_id($$class->supplier_id);
} else if (!empty($_GET['supplier_site_id'])) {
 $supplier_site_i = supplier_site::find_by_id($_GET['supplier_site_id']);
 if ($supplier_site_i) {
  foreach ($supplier_site_i as $k => $v) {
   $$class_second->$k = $v;
  }
 }
}

//check all the assigned business orgs
if (!empty($supplier->supplier_id)) {
 $supplier_file = extn_file::find_by_reference_table_and_id('supplier', $supplier->supplier_id);
 $all_bus = org::find_all_business();
 $assigned_bus = supplier_bu::find_all_assigned_org_ids($supplier->supplier_id);
 $assigned_bu_statement = "<ul class='column header_field'>";
 foreach ($all_bus as $org_array) {
  $assigned_bu_statement .= "<li><label>$org_array->org : </label> ";
  if (in_array($org_array->org_id, $assigned_bus)) {
   $value = 1;
  } else {
   $value = "";
  }
  $assigned_bu_statement .= form::checkBox_field('assigned_bu', $value, '', '1');
  $assigned_bu_statement .= " <a href=\"" . HOME_URL . "form.php?class_name=supplier_bu&supplier_id={$supplier->supplier_id}&org_id={$org_array->org_id}&mode=$mode\">Assignment Details</a></li>";
 }
 $assigned_bu_statement .="</ul>";
}

if (!empty($supplier_site->supplier_site_id)) {
 $site_file = extn_file::find_by_reference_table_and_id('supplier_site', $supplier_site->supplier_site_id);
}

if (!empty($$class->ar_customer_id)) {
 $$class->customer_name = ar_customer::find_by_id($$class->ar_customer_id)->customer_name;
}
?>