function api_get_inventories($return_type, $param) { $inventories = get_inventories(); $ret = ''; if ($return_type == 'xml') { $ret = "<xml>\n"; } if (empty($inventories)) { $ret .= "false"; } foreach ($inventories as $index => $item) { switch ($return_type) { case "xml": $ret .= "<inventory>\n"; $ret .= "<id>" . $index . "</id>\n"; $ret .= "<name>" . $item . "</name>\n"; $ret .= "</inventory>\n"; break; case "csv": $ret .= array_to_csv(array($index, $item)); break; } } if ($return_type == 'xml') { $ret .= "</xml>\n"; } return $ret; }
<?php session_start(); if (!isset($_SESSION['imonggo_api_token'])) { header('Location:login.php'); } include 'post_get.php'; //Gets products available on-hand $inventories = array_filter(get_inventories()); //Gets tags for checkbox creation $get_output = get_products(); $response = $get_output[0]; $tags = $get_output[1]; if (isset($_GET['post_products'])) { if (!empty($inventories)) { $post_tags = $_GET['checkbox_name']; post_products($response, $post_tags, $inventories); } else { $error_msg = "Error: No product available"; echo $error_msg; } if (isset($_GET['post_all_products'])) { if (!empty($inventories)) { get_all_products($inventories); } else { $error_msg = "Error: No product available"; echo $error_msg; } } } elseif (isset($_GET['pull_customers'])) { get_customers();