public function put($rest, $id)
 {
     $req = $rest->request();
     $info = $req->post();
     $old_cost = get_standard_cost($id);
     $update_no = stock_cost_update($id, $info['material_cost'], $info['labour_cost'], $info['overhead_cost'], $old_cost);
     api_success_response(json_encode(array('stock_id' => $id)));
 }
 public function get($rest)
 {
     $locations = get_item_locations(false);
     $ret = array();
     while ($loc = db_fetch($locations)) {
         $ret[] = array('loc_code' => $loc['loc_code'], 'location_name' => $loc['location_name'], 'delivery_address' => $loc['delivery_address'], 'phone' => $loc['phone'], 'phone2' => $loc['phone2'], 'fax' => $loc['fax'], 'email' => $loc['email'], 'contact' => $loc['contact']);
     }
     api_success_response(json_encode($ret));
 }
 private function glaccounts_all($from = null)
 {
     if ($from == null) {
         $from = 0;
     }
     $sql = "SELECT " . TB_PREF . "chart_master.*," . TB_PREF . "chart_types.name AS AccountTypeName FROM " . TB_PREF . "chart_master," . TB_PREF . "chart_types WHERE " . TB_PREF . "chart_master.account_type=" . TB_PREF . "chart_types.id ORDER BY account_code LIMIT " . $from . ", " . RESULTS_PER_PAGE;
     $query = db_query($sql, "error");
     $info = array();
     while ($data = db_fetch($query, "error")) {
         $info[] = array('account_code' => $data['account_code'], 'account_name' => $data['account_name'], 'account_type' => $data['account_type'], 'account_code2' => $data['account_code2']);
     }
     api_success_response(json_encode($info));
 }
 private function taxgroups_all($from = null)
 {
     if ($from == null) {
         $from = 0;
     }
     $sql = "SELECT * FROM " . TB_PREF . "tax_groups WHERE !inactive LIMIT " . $from . ", " . RESULTS_PER_PAGE;
     $query = db_query($sql, "error");
     $info = array();
     while ($data = db_fetch($query, "error")) {
         $info[] = array('id' => $data['id'], 'name' => $data['name'], 'tax_shipping' => $data['tax_shipping']);
     }
     api_success_response(json_encode($info));
 }
 private function bankaccounts_all($from = null)
 {
     if ($from == null) {
         $from = 0;
     }
     $sql = "SELECT * FROM " . TB_PREF . "bank_accounts LIMIT " . $from . ", " . RESULTS_PER_PAGE;
     $query = db_query($sql, "error");
     $info = array();
     while ($data = db_fetch($query, "error")) {
         $info[] = array("id" => $data["id"], "account_type" => $data["account_type"], "account_code" => $data["account_code"], "bank_account_name" => $data["bank_account_name"], "bank_name" => $data["bank_name"], "bank_account_number" => $data["bank_account_number"], "bank_curr_code" => $data["bank_curr_code"], "bank_address" => $data["bank_address"], "dflt_curr_act" => $data["dflt_curr_act"]);
     }
     api_success_response(json_encode($info));
 }
 private function currencies_all($from = null)
 {
     if ($from == null) {
         $from = 0;
     }
     $sql = "SELECT * FROM " . TB_PREF . "currencies WHERE !inactive LIMIT " . $from . ", " . RESULTS_PER_PAGE;
     $query = db_query($sql, "error");
     $info = array();
     while ($data = db_fetch($query, "error")) {
         $info[] = array('curr_abrev' => $data['curr_abrev'], 'currency' => $data['currency'], 'curr_symbol' => $data['curr_symbol'], 'country' => $data['country'], 'hundreds_name' => $data['hundreds_name']);
     }
     api_success_response(json_encode($info));
 }
 private function taxtypes_all($from = null)
 {
     if ($from == null) {
         $from = 0;
     }
     $sql = "SELECT * FROM " . TB_PREF . "item_tax_types LIMIT " . $from . ", " . RESULTS_PER_PAGE;
     $query = db_query($sql, "error");
     $info = array();
     while ($data = db_fetch($query, "error")) {
         $info[] = array('id' => $data['id'], 'name' => $data['name'], 'exempt' => $data['exempt']);
     }
     api_success_response(json_encode($info));
 }
 private function supplier_all($from = null)
 {
     if ($from == null) {
         $from = 0;
     }
     $sql = "SELECT * FROM " . TB_PREF . "suppliers LIMIT " . $from . ", " . RESULTS_PER_PAGE;
     $query = db_query($sql, "error");
     $info = array();
     while ($data = db_fetch_assoc($query, "error")) {
         $info[] = $data;
     }
     api_success_response(json_encode($info));
 }
 private function category_all($from = null)
 {
     $sql = "SELECT c.*, t.name as tax_name FROM " . TB_PREF . "stock_category c, " . TB_PREF . "item_tax_types t WHERE c.dflt_tax_type=t.id";
     if ($from !== null) {
         $sql .= "LIMIT " . $from . ", " . RESULTS_PER_PAGE;
     }
     $query = db_query($sql, "error");
     $info = array();
     while ($data = db_fetch($query, "error")) {
         $info[] = array('category_id' => $data['category_id'], 'description' => $data['description'], 'dflt_tax_type' => $data['dflt_tax_type'], 'dflt_units' => $data['dflt_units'], 'dflt_mb_flag' => $data['dflt_mb_flag'], 'dflt_sales_act' => $data['dflt_sales_act'], 'dflt_cogs_act' => $data['dflt_cogs_act'], 'dflt_inventory_act' => $data['dflt_inventory_act'], 'dflt_adjustment_act' => $data['dflt_adjustment_act'], 'dflt_assembly_act' => $data['dflt_assembly_act'], 'dflt_no_sale' => $data['dflt_no_sale']);
     }
     api_success_response(json_encode($info));
 }
 function inventory_delete($id)
 {
     $app = \Slim\Slim::getInstance('SASYS');
     $req = $app->request();
     $info = $req->post();
     $itm = get_item($id);
     if ($itm == null) {
         api_error(400, 'Invalid Stock Id');
     }
     delete_item($id);
     $itm = get_item($id);
     if ($itm != null) {
         api_error(500, 'Could Not Delete from Database');
     } else {
         api_success_response("Item has been deleted");
     }
 }