public function delete($rest, $id) { $req = $rest->request(); $info = $req->post(); $sup = get_supplier($id); if ($sup == null) { api_error(400, 'Invalid Supplier ID'); } delete_supplier($id); $sup = null; $sup = get_supplier($id); if ($sup != null) { api_error(500, 'Could Not Delete from Database'); } else { api_success_response("Supplier has been deleted"); } }
} } elseif (isset($_POST['delete']) && $_POST['delete'] != "") { //the link to delete a selected record was clicked instead of the submit button $cancel_delete = 0; // PREVENT DELETES IF DEPENDENT RECORDS IN 'supp_trans' , purch_orders if (key_in_foreign_table($_POST['supplier_id'], 'supp_trans', 'supplier_id')) { $cancel_delete = 1; display_error(_("Cannot delete this supplier because there are transactions that refer to this supplier.")); } else { if (key_in_foreign_table($_POST['supplier_id'], 'purch_orders', 'supplier_id')) { $cancel_delete = 1; display_error(_("Cannot delete the supplier record because purchase orders have been created against this supplier.")); } } if ($cancel_delete == 0) { delete_supplier($_POST['supplier_id']); unset($_SESSION['supplier_id']); $supplier_id = ''; $Ajax->activate('_page_body'); } //end if Delete supplier } start_form(); if (db_has_suppliers()) { start_table(false, "", 3); // start_table(TABLESTYLE_NOBORDER); start_row(); supplier_list_cells(_("Select a supplier: "), 'supplier_id', null, _('New supplier'), true, check_value('show_inactive')); check_cells(_("Show inactive:"), 'show_inactive', null, true); end_row(); end_table();
<?php // Load the Supplier classes require_once 'include.php'; // Load the Translation for this Module if (!xml2php('supplier')) { $smarty->assign('error_msg', "Error in language file"); } $supplierID = $VAR['supplierID']; // Make sure we got an Supplier ID number if (!isset($supplierID) || $supplierID == "") { $smarty->assign('results', 'Please go back and select an supplier record'); die; } // Delete the supplier function call if (!delete_supplier($db, $supplierID)) { force_page('core', 'error&error_msg=MySQL Error: ' . $db->ErrorMsg() . '&menu=1&type=database'); exit; } else { force_page('supplier', 'view&page_title=Supplier'); exit; }
$dbc = mysql_connect('localhost', 'root', 'rishi'); if (!$dbc) { die('NOT CONNECTED:' . mysql_error()); } $db_selected = mysql_select_db("restaurant", $dbc); if (!$db_selected) { die('NOT CONNECTED TO DATABASE:' . mysql_error()); } if (empty($supplier)) { echo "<script type=\"text/javascript\">" . "\n"; echo "alert(\"No Suppliers Selected!!!\");" . "\n"; echo "</script>" . "\n"; echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=admin.html\">" . "\n"; } else { $num_supp = count($supplier); for ($i = 0; $i < $num_supp; $i++) { $query = "DELETE FROM SUPPLIER WHERE Contact = {$supplier[$i]};"; mysql_query($query); } echo "<script type=\"text/javascript\">" . "\n"; echo "alert(\"Selected Suppliers Deleted!!!\");" . "\n"; echo "</script>" . "\n"; echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=admin.html\">" . "\n"; } } delete_supplier($_POST["supplier"]); ?> </html> </body> </html>
switch ($_GET['action']) { case 'add_supplier': add_supplier(); break; case 'get_supplier': get_supplier(); break; case 'edit_product': edit_product(); break; case 'get_suppliers': get_suppliers(); break; case 'delete_supplier': delete_supplier(); break; case 'update_supplier': update_supplier(); break; } function add_supplier() { $data = json_decode(file_get_contents("php://input")); $suppliername = mysql_real_escape_string($data->suppliername); $supplieraddress = mysql_real_escape_string($data->supplieraddress); $supplierphone = mysql_real_escape_string($data->supplierphone); $supplieremail = mysql_real_escape_string($data->supplieremail); $supplieritem = mysql_real_escape_string($data->supplieritem); $supplierunitprice = mysql_real_escape_string($data->supplierunitprice); $supplierstatues = 1;