} else { if ($form_id == 10) { ///edit vendor if (isset($_POST['vendor_id']) and !empty($_POST['vendor_id']) and isset($_POST['vendor_name']) and !empty($_POST['vendor_name']) and isset($_POST['contact_number']) and !empty($_POST['contact_number']) and isset($_POST['tin_number']) and !empty($_POST['tin_number']) and isset($_POST['contact_address']) and !empty($_POST['contact_address'])) { $vendor = new wendors(); $vendor->id = $_POST['vendor_id']; $vendor->getWendor(); $vendor->contact_address = $_POST['contact_address']; $vendor->contact_no = $_POST['contact_number']; $vendor->wendor_name = $_POST['vendor_name']; $vendor->wendor_tin_number = $_POST['tin_number']; if ($vendor->updateWendor()) { $message = "Vendor Updated Successfuly"; $responce = array('status' => 'success', 'error' => '', 'data' => array("message" => $message, "id" => $vendor->id)); } else { $description = "Vendor update failed, vendor : " . $vendor->to_string(); Log::e($tag, $description); $mysql_error = mysql_error(); if (empty($mysql_error)) { $error_message = 'Some server error occured'; } else { $error_message = $mysql_error; } $responce = array('status' => 'failed', 'error' => $error_message, 'data' => array()); } } else { $responce = array('status' => 'failed', 'error' => 'Data missing', 'data' => array()); } } else { if ($form_id == 11) { ///edit item
} else { $responce = array('status' => 'failed', 'error' => 'Data missing', 'data' => array()); } } else { if ($form_id == 10) { //vendor form if (isset($_POST['vendor_name']) and !empty($_POST['vendor_name']) and isset($_POST['contact_number']) and !empty($_POST['contact_number']) and isset($_POST['tin_number']) and !empty($_POST['tin_number']) and isset($_POST['contact_address']) and !empty($_POST['contact_address'])) { $vendor = new wendors(); $vendor->wendor_name = $_POST['vendor_name']; $vendor->contact_no = $_POST['contact_number']; $vendor->wendor_tin_number = $_POST['tin_number']; $vendor->contact_address = $_POST['contact_address']; if ($vendor->addWendor()) { $responce = array('status' => 'success', 'error' => '', 'data' => array('message' => 'Vendor Added successfully')); } else { Log::e($tag, "Vendor adding failed item : " . $vendor->to_string()); $mysql_error = mysql_error(); if (empty($mysql_error)) { $error_message = 'Some server error occured'; } else { $error_message = $mysql_error; } $responce = array('status' => 'failed', 'error' => $error_message, 'data' => array()); } } else { $responce = array('status' => 'failed', 'error' => 'Data missing', 'data' => array()); } } else { if ($form_id == 11) { //item form if (isset($_POST['item_code']) and !empty($_POST['item_code']) and isset($_POST['item_name']) and !empty($_POST['item_name']) and isset($_POST['mrp']) and isset($_POST['tax_category_id']) and !empty($_POST['tax_category_id']) and isset($_POST['purchace_rate']) and isset($_POST['discount_percent']) and isset($_POST['unit']) and !empty($_POST['unit'])) {
$responce = array('status' => 'failed', 'error' => $error_message, 'data' => array()); } } else { $responce = array('status' => 'failed', 'error' => 'Data missing', 'data' => array()); } } else { if ($form_id == 18) { ///vendor delete if (isset($_POST['vendor_id']) and !empty($_POST['vendor_id'])) { $vendor = new wendors(); $vendor->id = $_POST['vendor_id']; if ($vendor->deleteWendor()) { $message = "Vendor deleted Successfuly"; $responce = array('status' => 'success', 'error' => '', 'data' => array("message" => $message, "id" => $vendor->id)); } else { $description = "Vendor delete failed, item : " . $vendor->to_string(); Log::e($tag, $description); $mysql_error = mysql_error(); if (empty($mysql_error)) { $error_message = 'Some server error occured'; } else { $error_message = $mysql_error; } $responce = array('status' => 'failed', 'error' => $error_message, 'data' => array()); } } else { $responce = array('status' => 'failed', 'error' => 'Data missing', 'data' => array()); } } else { if ($form_id == 19) { ///purchace delete