public function post($rest) { // Originally added by Richard Vinke $req = $rest->request(); $info = $req->post(); // ToDo Check if loc_code already exists // Validate Required Fields if (!isset($info['loc_code'])) { api_error(412, 'Stock Id is required'); } if (!isset($info['location_name'])) { api_error(412, 'Stock Id is required'); } if (!isset($info['delivery_address'])) { $info['delivery_address'] = ''; } if (!isset($info['phone'])) { $info['phone'] = ''; } if (!isset($info['phone2'])) { $info['phone2'] = ''; } if (!isset($info['fax'])) { $info['fax'] = ''; } if (!isset($info['email'])) { $info['email'] = ''; } if (!isset($info['contact'])) { $info['contact'] = ''; } add_item_location($info['loc_code'], $info['location_name'], $info['delivery_address'], $info['phone'], $info['phone2'], $info['fax'], $info['email'], $info['contact']); $itm = get_item_location($info['loc_code']); if ($itm != null) { api_create_response(json_encode($itm)); } else { api_error(500, 'Could Not Save to Database'); } }
label_cell($myrow["phone2"]); inactive_control_cell($myrow["loc_code"], $myrow["inactive"], 'locations', 'loc_code'); edit_button_cell("Edit" . $myrow["loc_code"], _("Edit")); delete_button_cell("Delete" . $myrow["loc_code"], _("Delete")); end_row(); } //END WHILE LIST LOOP inactive_control_row($th); end_table(); echo '<br>'; start_table(TABLESTYLE2); $_POST['email'] = ""; if ($selected_id != -1) { //editing an existing Location if ($Mode == 'Edit') { $myrow = get_item_location($selected_id); $_POST['loc_code'] = $myrow["loc_code"]; $_POST['location_name'] = $myrow["location_name"]; $_POST['delivery_address'] = $myrow["delivery_address"]; $_POST['contact'] = $myrow["contact"]; $_POST['phone'] = $myrow["phone"]; $_POST['phone2'] = $myrow["phone2"]; $_POST['fax'] = $myrow["fax"]; $_POST['email'] = $myrow["email"]; } hidden("selected_id", $selected_id); hidden("loc_code"); label_row(_("Location Code:"), $_POST['loc_code']); } else { //end of if $selected_id only do the else when a new record is being entered text_row(_("Location Code:"), 'loc_code', null, 5, 5);