<?php

if (!empty($_GET["customer_number"]) && (!is_array($_GET["customer_number"]))) {
 $customer_number = $_GET["customer_number"];
 $customer = ar_customer::find_by_customerNumber($customer_number);
}

if (empty($$class->ar_customer_id) && !empty($_GET['ar_customer_site_id'])) {
 $cust_site_i = ar_customer_site::find_by_id($_GET['ar_customer_site_id']);
 foreach ($cust_site_i as $k => $v) {
  $$class_second->$k = $v;
 }
 $$class->ar_customer_id = $$class_second->ar_customer_id;
 $$class->findBy_id($$class->ar_customer_id);
} else if (!empty($_GET['ar_customer_site_id'])) {
 $cust_site_i = ar_customer_site::find_by_id($_GET['ar_customer_site_id']);
 if ($cust_site_i) {
  foreach ($cust_site_i as $k => $v) {
   $$class_second->$k = $v;
  }
 }
}

//check all the assigned business orgs
if (!empty($$class->ar_customer_id)) {
 $customer_file = extn_file::find_by_reference_table_and_id('ar_customer', $$class->ar_customer_id);
 $all_bus = org::find_all_business();
 $assigned_bus = ar_customer_bu::find_all_assigned_org_ids($$class->ar_customer_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 class='ajax-link' href=\"form.php?class_name=ar_customer_bu&mode=9&ar_customer_id={$$class->ar_customer_id}&org_id={$org_array->org_id}\">Assignment Details</a></li>";
 }
 $assigned_bu_statement .="</ul>";
}

if (!empty($$class->supplier_id)) {
 $supp_details = supplier::find_by_id($$class->supplier_id);
  $$class->supplier_name = $supp_details->supplier_name;
}

if (!empty($customer_site->ar_customer_site_id)) {
 $site_file = extn_file::find_by_reference_table_and_id('customer_site', $customer_site->ar_customer_site_id);
}
?>
